This file is indexed.

/usr/share/doc/libhwloc-doc/sharedcaches.c is in libhwloc-doc 1.11.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* This example program looks for caches shared between this process
 * and another one based on their current binding.
 *
 * Copyright © 2014 Inria.  All rights reserved.
 * See COPYING in top-level directory.
 */

#include <hwloc.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
  pid_t hispid;
  hwloc_topology_t topology;
  hwloc_bitmap_t set, hisset;
  hwloc_obj_t obj;
  int err;

  /* find the pid of the other process, otherwise use my own pid */
  if (argc >= 2) {
    hispid = atoi(argv[1]);
  } else {
    hispid = getpid();
  }

  /* create a topology with instruction caches enables */
  err = hwloc_topology_init(&topology);
  if (err < 0) {
    fprintf(stderr, "failed to initialize the topology\n");
    return EXIT_FAILURE;
  }
  hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_ICACHES);
  err = hwloc_topology_load(topology);
  if (err < 0) {
    fprintf(stderr, "failed to load the topology\n");
    hwloc_topology_destroy(topology);
    return EXIT_FAILURE;
  }

  /* find where I am running */
  set = hwloc_bitmap_alloc();
  if (!set) {
    fprintf(stderr, "failed to allocate my bitmap\n");
    hwloc_topology_destroy(topology);
    return EXIT_FAILURE;
  }
  err = hwloc_get_cpubind(topology, set, 0);
  if (err < 0) {
    fprintf(stderr, "failed to get my binding\n");
    hwloc_bitmap_free(set);
    hwloc_topology_destroy(topology);
    return EXIT_FAILURE;
  }
    
  /* find where the other process is running */
  hisset = hwloc_bitmap_alloc();
  if (!hisset) {
    fprintf(stderr, "failed to allocate his bitmap\n");
    hwloc_bitmap_free(set);
    hwloc_topology_destroy(topology);
    return EXIT_FAILURE;
  }
  err = hwloc_get_proc_cpubind(topology, hispid, hisset, 0);
  if (err < 0) {
    fprintf(stderr, "failed to get his binding\n");
    hwloc_bitmap_free(hisset);
    hwloc_bitmap_free(set);
    hwloc_topology_destroy(topology);
    return EXIT_FAILURE;
  }

  /* merge both process binding into mine */
  hwloc_bitmap_or(set, set, hisset);

  /* find the smallest object covering this set */
  obj = hwloc_get_obj_covering_cpuset(topology, set);

  /* display parents of type cache */
  while (obj) {
    if (obj->type == HWLOC_OBJ_CACHE) {
      char type[64];
      char attr[64];
      hwloc_obj_type_snprintf(type, sizeof(type), obj, 0);
      hwloc_obj_attr_snprintf(attr, sizeof(attr), obj, ", ", 0);
      printf("Found object %s with attributes %s\n", type, attr);
    }
    /* next parent up in the tree */
    obj = obj->parent;
  }

  hwloc_bitmap_free(hisset);
  hwloc_bitmap_free(set);
  hwloc_topology_destroy(topology);
  return EXIT_SUCCESS;
}