Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] create-namespace: Add percentage option #209

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vliaskov
Copy link

@vliaskov vliaskov commented Jun 21, 2022

I am not sure this option would make sense, so I 've opened an RFC/wip for discussion.

The size option of the create-namespace command can now take a percentage of
the total region size as the desired size. E.g. :

ndctl create-namespace -s 50%

will create a namespace using half of the total region size, assuming
there is enough available capacity in the region for the request.

Only whole percentages are correctly parsed at the moment e.g. 12%, but
not 12.5%.

Sizes that result in a misaligned size with regards to region alignment
(default 16MB) are rounded down, unless the rounded-up size would result
in using the full remaining region capacity available.

Fixes: #199
Signed-off-by: Vasilis Liaskovitis [email protected]

The size option of the create-namespace command can now take a percentage of
the total region size as the desired size. E.g. :

ndctl create-namespace  -s 50%

will create a namespace using half of the total region size, assuming
there is enough available capacity in the region for the request.

Only whole percentages are correctly parsed at the moment e.g. 12%, but
not 12.5%.

Sizes that result in a misaligned size with regards to region alignment
(default 16MB) are rounded down, unless the rounded-up size would result
in using the full remaining region capacity available.

Fixes: pmem#199
Signed-off-by: Vasilis Liaskovitis <[email protected]>
@vliaskov
Copy link
Author

vliaskov commented Jun 21, 2022

Example allocating 50%, 25%, 13%, 12% of a region. The 13% and 12% percentages result in sizes that are rounded-down and up respectively. In the end the whole capacity is used as expected.

:~ # ndctl list -R
[
  {
    "dev":"region0",
    "size":135291469824,
    "align":16777216,
    "available_size":135291469824,
    "max_available_extent":135291469824,
    "type":"pmem",
    "iset_id":-5584504699223897566,
    "persistence_domain":"memory_controller"
  }
]

:~ # ndctl  create-namespace  -s 50%  --verbose
validate_available_percentage:683: region0: percentage requested: 50 of total region size: 1f80000000 size requested: fc0000000 avail: 1f80000000
{
  "dev":"namespace0.0",
  "mode":"fsdax",
  "map":"dev",
  "size":"62.01 GiB (66.59 GB)",
  "uuid":"b11f4e90-150a-4a5b-a11b-2737cafca435",
  "sector_size":512,
  "align":2097152,
  "blockdev":"pmem0"
}
created 1 namespace

:~ # ndctl  create-namespace  -s 25%  --verbose
validate_available_percentage:683: region0: percentage requested: 25 of total region size: 1f80000000 size requested: 7e0000000 avail: fc0000000
{
  "dev":"namespace0.3",
  "mode":"fsdax",
  "map":"dev",
  "size":"31.01 GiB (33.29 GB)",
  "uuid":"1bd019a7-edb1-4817-981d-fba4679fe907",
  "sector_size":512,
  "align":2097152,
  "blockdev":"pmem0.3"
}
created 1 namespace

:~ # ndctl  create-namespace  -s 13%  --verbose
validate_available_percentage:671: region0: percentage 13 of total region size: 0x1f80000000 results in unaligned size: 0x41851eb85 (align setting 0x1000000) rounding down to size: 0x418000000
validate_available_percentage:683: region0: percentage requested: 13 of total region size: 1f80000000 size requested: 418000000 avail: 7e0000000
{
  "dev":"namespace0.1",
  "mode":"fsdax",
  "map":"dev",
  "size":"16.12 GiB (17.31 GB)",
  "uuid":"9e4a6b62-8287-48ee-8922-36a60682cd23",
  "sector_size":512,
  "align":2097152,
  "blockdev":"pmem0.1"
}
created 1 namespace

:~ # ndctl  create-namespace  -s 12%  --verbose
validate_available_percentage:664: region0: percentage 12 of total region size: 0x1f80000000 results in unaligned size: 0x3c7ae147a (align setting 0x1000000) rounding up to size: 0x3c8000000
validate_available_percentage:683: region0: percentage requested: 12 of total region size: 1f80000000 size requested: 3c8000000 avail: 3c8000000
{
  "dev":"namespace0.2",
  "mode":"fsdax",
  "map":"dev",
  "size":"14.89 GiB (15.98 GB)",
  "uuid":"05d6aa81-61ea-409c-99a2-4b3a1cb85ad4",
  "sector_size":512,
  "align":2097152,
  "blockdev":"pmem0.2"
}
created 1 namespace

:~ # ndctl list -N
[
  {
    "dev":"namespace0.2",
    "mode":"fsdax",
    "map":"dev",
    "size":15984492544,
    "uuid":"05d6aa81-61ea-409c-99a2-4b3a1cb85ad4",
    "sector_size":512,
    "align":2097152,
    "blockdev":"pmem0.2"
  },
  {
    "dev":"namespace0.1",
    "mode":"fsdax",
    "map":"dev",
    "size":17305698304,
    "uuid":"9e4a6b62-8287-48ee-8922-36a60682cd23",
    "sector_size":512,
    "align":2097152,
    "blockdev":"pmem0.1"
  },
  {
    "dev":"namespace0.3",
    "mode":"fsdax",
    "map":"dev",
    "size":33292288000,
    "uuid":"1bd019a7-edb1-4817-981d-fba4679fe907",
    "sector_size":512,
    "align":2097152,
    "blockdev":"pmem0.3"
  },
  {
    "dev":"namespace0.0",
    "mode":"fsdax",
    "map":"dev",
    "size":66586673152,
    "uuid":"b11f4e90-150a-4a5b-a11b-2737cafca435",
    "sector_size":512,
    "align":2097152,
    "blockdev":"pmem0"
  }
]

:~ # ndctl list -R
[
  {
    "dev":"region0",
    "size":135291469824,
    "align":16777216,
    "available_size":0,
    "max_available_extent":0,
    "type":"pmem",
    "iset_id":-5584504699223897566,
    "persistence_domain":"memory_controller"
  }
] ````

@vliaskov
Copy link
Author

Generally though, the constant rounding-down and final rounding-up leaves unused space in the region, obviously. E.g. trying to allocate namespaces with following percentages:

40%, 30%, 15%, 10%, 5%

does leave 32 MB unused in the region in the end, although in theory the user would expect all capacity (100%) to be used.

:~ # ndctl  create-namespace  --size 40%  --verbose
validate_available_percentage:671: region0: percentage 40 of total region size: 0x1f80000000 results in unaligned size: 0xc99999999 (align setting 0x1000000) rounding down to size: 0xc99000000
validate_available_percentage:683: region0: percentage requested: 40 of total region size: 1f80000000 size requested: c99000000 avail: 1f80000000
^[[A{
  "dev":"namespace0.0",
  "mode":"fsdax",
  "map":"dev",
  "size":"49.60 GiB (53.26 GB)",
  "uuid":"b30d45de-4669-4261-9a95-72046ae6fb3e",
  "sector_size":512,
  "align":2097152,
  "blockdev":"pmem0"
}
created 1 namespace

:~ # ndctl  create-namespace  --size 30%  --verbose
validate_available_percentage:671: region0: percentage 30 of total region size: 0x1f80000000 results in unaligned size: 0x973333333 (align setting 0x1000000) rounding down to size: 0x973000000
validate_available_percentage:683: region0: percentage requested: 30 of total region size: 1f80000000 size requested: 973000000 avail: 12e7000000
{
  "dev":"namespace0.4",
  "mode":"fsdax",
  "map":"dev",
  "size":"37.21 GiB (39.95 GB)",
  "uuid":"10bb3f46-8b07-4df1-9bf9-7c19e92cd132",
  "sector_size":512,
  "align":2097152,
  "blockdev":"pmem0.4"
}
created 1 namespace

:~ # ndctl  create-namespace  --size 15%  --verbose
validate_available_percentage:671: region0: percentage 15 of total region size: 0x1f80000000 results in unaligned size: 0x4b9999999 (align setting 0x1000000) rounding down to size: 0x4b9000000
validate_available_percentage:683: region0: percentage requested: 15 of total region size: 1f80000000 size requested: 4b9000000 avail: 974000000
{
  "dev":"namespace0.1",
  "mode":"fsdax",
  "map":"dev",
  "size":"18.59 GiB (19.96 GB)",
  "uuid":"18ea3e03-0696-43bd-9028-9a234cfc9ac2",
  "sector_size":512,
  "align":2097152,
  "blockdev":"pmem0.1"
}
created 1 namespace

:~ # ndctl  create-namespace  --size 10%  --verbose
validate_available_percentage:671: region0: percentage 10 of total region size: 0x1f80000000 results in unaligned size: 0x326666666 (align setting 0x1000000) rounding down to size: 0x326000000
validate_available_percentage:683: region0: percentage requested: 10 of total region size: 1f80000000 size requested: 326000000 avail: 4bb000000
{
  "dev":"namespace0.2",
  "mode":"fsdax",
  "map":"dev",
  "size":"12.40 GiB (13.31 GB)",
  "uuid":"a2a9ce11-8fa9-43e3-bf88-046ba0c21441",
  "sector_size":512,
  "align":2097152,
  "blockdev":"pmem0.2"
}
created 1 namespace

:~ # ndctl  create-namespace  --size 5%  --verbose
validate_available_percentage:671: region0: percentage 5 of total region size: 0x1f80000000 results in unaligned size: 0x193333333 (align setting 0x1000000) rounding down to size: 0x193000000
validate_available_percentage:683: region0: percentage requested: 5 of total region size: 1f80000000 size requested: 193000000 avail: 195000000
{
  "dev":"namespace0.3",
  "mode":"fsdax",
  "map":"dev",
  "size":"6.20 GiB (6.65 GB)",
  "uuid":"1e369a90-036a-4121-9057-7521874c4f8b",
  "sector_size":512,
  "align":2097152,
  "blockdev":"pmem0.3"
}

created 1 namespace
:~ # ndctl  list -R
[
  {
    "dev":"region0",
    "size":135291469824,
    "align":16777216,
    "available_size":33554432,
    "max_available_extent":33554432,
    "type":"pmem",
    "iset_id":-5584504699223897566,
    "persistence_domain":"memory_controller"
  }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ndctl create-namespace should support percentages
1 participant