#./shmns4 shmns4: One process creates and maps shm segments in multiple namespaces. The namespaces are replaced before unmapping the segments. 1) unshare(0x8000000). create a namespace, create 2 shm segments, do not map them. 2) unshare(0x8000000). [ 71.444890] newseg(): shp ffff888003a84f00: shp->shm_nattch 0 ->shmfile ffff88800428f500. [ 71.448696] newseg(): shp ffff888003a84e00: shp->shm_nattch 0 ->shmfile ffff88800428f900. 2) unshare(0x8000000). [ 71.453352] shm_may_destroy(): shp ffff888003a84e00: shp->shm_nattch 0. [ 71.455822] shm_may_destroy(): shp ffff888003a84f00: shp->shm_nattch 0. [ 71.460332] namespace ffff888003679400: in exit_ns. [ 71.461783] namespace ffff888003679400: end of exit_ns. create a namespace, create 2 shm segments, do not map them, no auto-rm. [ 76.481527] newseg(): shp ffff888003a84f00: shp->shm_nattch 0 ->shmfile ffff88800428f800. [ 76.486162] newseg(): shp ffff888003a84e00: shp->shm_nattch 0 ->shmfile ffff88800428f900. 2) unshare(0x8000000). [ 76.496480] namespace ffff888003679800: in exit_ns. [ 76.499758] do_shm_rmid(): shp ffff888003a84f00: shp->shm_nattch 0. [ 76.515934] do_shm_rmid(): shp ffff888003a84e00: shp->shm_nattch 0. [ 76.537126] namespace ffff888003679800: end of exit_ns. create a namespace, create 2 shm segments, map them. [ 81.517464] newseg(): shp ffff888003a84e00: shp->shm_nattch 0 ->shmfile ffff88800428f800. [ 81.526964] do_shmat(): shp ffff888003a84e00: shp->shm_nattch 0. [ 81.531575] do_shmat(): shp ffff888003a84e00: get_ipc_ns(). [ 81.542459] __shm_open(): before ++: shp ffff888003a84e00, sfd->file ffff88800428f800: shp->shm_nattch 1. [ 81.549390] do_shmat() before --: shp ffff888003a84e00: shp->shm_nattch 2. [ 81.554699] shm_may_destroy(): shp ffff888003a84e00: shp->shm_nattch 1. [ 81.560649] newseg(): shp ffff888003a84f00: shp->shm_nattch 0 ->shmfile ffff88800428f500. [ 81.564649] do_shmat(): shp ffff888003a84f00: shp->shm_nattch 0. [ 81.568681] do_shmat(): shp ffff888003a84f00: get_ipc_ns(). [ 81.573865] __shm_open(): before ++: shp ffff888003a84f00, sfd->file ffff88800428f500: shp->shm_nattch 1. [ 81.576866] do_shmat() before --: shp ffff888003a84f00: shp->shm_nattch 2. [ 81.580494] shm_may_destroy(): shp ffff888003a84f00: shp->shm_nattch 1. 2) unshare(0x8000000). [ 81.589648] shm_may_destroy(): shp ffff888003a84f00: shp->shm_nattch 1. [ 81.592431] shm_may_destroy(): shp ffff888003a84e00: shp->shm_nattch 1. Once more: Create a namespace, create 2 shm segments, map them, no auto-rm. [ 86.609807] newseg(): shp ffff888003a84000: shp->shm_nattch 0 ->shmfile ffff888004023a00. [ 86.613978] do_shmat(): shp ffff888003a84000: shp->shm_nattch 0. [ 86.616616] do_shmat(): shp ffff888003a84000: get_ipc_ns(). [ 86.621714] __shm_open(): before ++: shp ffff888003a84000, sfd->file ffff888004023a00: shp->shm_nattch 1. [ 86.625975] do_shmat() before --: shp ffff888003a84000: shp->shm_nattch 2. [ 86.629578] shm_may_destroy(): shp ffff888003a84000: shp->shm_nattch 1. [ 86.633766] newseg(): shp ffff888003a84100: shp->shm_nattch 0 ->shmfile ffff888004023e00. [ 86.639642] do_shmat(): shp ffff888003a84100: shp->shm_nattch 0. [ 86.643634] do_shmat(): shp ffff888003a84100: get_ipc_ns(). [ 86.646951] __shm_open(): before ++: shp ffff888003a84100, sfd->file ffff888004023e00: shp->shm_nattch 1. [ 86.651648] do_shmat() before --: shp ffff888003a84100: shp->shm_nattch 2. [ 86.660527] shm_may_destroy(): shp ffff888003a84100: shp->shm_nattch 1. Orphan namespace (switch back to parent namespace). Before exit of child: 4 mappings exist in 2 namespaces. [ 91.750385] shm_close(): before --: shp ffff888003a84100: shp->shm_nattch 1. [ 91.755503] shm_may_destroy(): shp ffff888003a84100: shp->shm_nattch 0. [ 91.758710] shm_close(): before --: shp ffff888003a84000: shp->shm_nattch 1. [ 91.761828] shm_may_destroy(): shp ffff888003a84000: shp->shm_nattch 0. [ 91.764879] shm_close(): before --: shp ffff888003a84f00: shp->shm_nattch 1. [ 91.768248] shm_may_destroy(): shp ffff888003a84f00: shp->shm_nattch 0. [ 91.772642] shm_close(): before --: shp ffff888003a84e00: shp->shm_nattch 1. [ 91.776417] shm_may_destroy(): shp ffff888003a84e00: shp->shm_nattch 0. [ 91.790861] shm_release: file ffff88800428f800, put_ipc_ns(). [ 91.796858] shm_release: file ffff88800428f500, put_ipc_ns(). [ 91.805866] namespace ffff888003679400: in exit_ns. [ 91.808458] namespace ffff888003679400: end of exit_ns. [ 91.816613] shm_release: file ffff888004023a00, put_ipc_ns(). [ 91.821392] shm_release: file ffff888004023e00, put_ipc_ns(). [ 91.825715] namespace ffff888003679800: in exit_ns. [ 91.828811] do_shm_rmid(): shp ffff888003a84000: shp->shm_nattch 0. [ 91.832453] do_shm_rmid(): shp ffff888003a84100: shp->shm_nattch 0. [ 91.843841] namespace ffff888003679800: end of exit_ns. parent:waitpid returned 285, status 0. [ 101.882842] namespace ffff888003679000: in exit_ns. [ 101.885707] namespace ffff888003679000: end of exit_ns. #