cxl/region: Recycle region ids
authorDan Williams <dan.j.williams@intel.com>
Fri, 4 Nov 2022 00:31:00 +0000 (17:31 -0700)
committerDan Williams <dan.j.williams@intel.com>
Fri, 4 Nov 2022 23:03:43 +0000 (16:03 -0700)
commit8f401ec1c8975eabfe4c089de91cbe058deabf71
treecc1d28f74278adbc2279efa2a926194f16b6f0f4
parente4f6dfa9ef756a3934a4caf618b1e86e9e8e21d0
cxl/region: Recycle region ids

At region creation time the next region-id is atomically cached so that
there is predictability of region device names. If that region is
destroyed and then a new one is created the region id increments. That
ends up looking like a memory leak, or is otherwise surprising that
identifiers roll forward even after destroying all previously created
regions.

Try to reuse rather than free old region ids at region release time.

While this fixes a cosmetic issue, the needlessly advancing memory
region-id gives the appearance of a memory leak, hence the "Fixes" tag,
but no "Cc: stable" tag.

Cc: Ben Widawsky <bwidawsk@kernel.org>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Fixes: 779dd20cfb56 ("cxl/region: Add region creation support")
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Link: https://lore.kernel.org/r/166752186062.947915.13200195701224993317.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core/region.c