- /* Calculate the shm allocation layout */
- shmsize = sizeof(struct shm_header);
- shmsize += offset_align(shmsize, __alignof__(struct channel));
- shmsize += sizeof(struct channel);
-
- /* Per-cpu buffer size: control (prior to backend) */
- shmsize += offset_align(shmsize, __alignof__(struct lib_ring_buffer));
- bufshmsize = sizeof(struct lib_ring_buffer);
- shmsize += bufshmsize * num_possible_cpus();
-
- /* Per-cpu buffer size: backend */
- shmsize += offset_align(shmsize, PAGE_SIZE);
- /* num_subbuf + 1 is the worse case */
- num_subbuf_alloc = num_subbuf + 1;
- bufshmsize = sizeof(struct lib_ring_buffer_backend_pages *) * num_subbuf_alloc;
- bufshmsize += offset_align(bufshmsize, PAGE_SIZE);
- bufshmsize += subbuf_size * num_subbuf_alloc;
- bufshmsize += offset_align(bufshmsize, __alignof__(struct lib_ring_buffer_backend_pages));
- bufshmsize += sizeof(struct lib_ring_buffer_backend_pages) * num_subbuf_alloc;
- bufshmsize += offset_align(bufshmsize, __alignof__(struct lib_ring_buffer_backend_subbuffer));
- bufshmsize += sizeof(struct lib_ring_buffer_backend_subbuffer) * num_subbuf;
- bufshmsize += offset_align(bufshmsize, PAGE_SIZE);
- shmsize += bufshmsize * num_possible_cpus();
-
- /* Per-cpu buffer size: control (after backend) */
- shmsize += offset_align(shmsize,
- max(__alignof__(struct commit_counters_hot),
- __alignof__(struct commit_counters_cold)));
- bufshmsize = sizeof(struct commit_counters_hot) * num_subbuf;
- bufshmsize += offset_align(bufshmsize, __alignof__(struct commit_counters_cold));
- bufshmsize += sizeof(struct commit_counters_cold) * num_subbuf;
- shmsize += bufshmsize * num_possible_cpus();