Re: 2.6.17-rc5-mm1

From: Christoph Lameter
Date: Tue Jun 06 2006 - 13:39:52 EST


On Tue, 6 Jun 2006, Hugh Dickins wrote:

> I'll go mad if I try to work it out again: I was as worried as you
> when I discovered that test in sys_swapon a year or so ago, apparently
> without any check on MAX_SWAPFILES; and went moaning to Andrew. But
> once I'd worked through swp_type, pte_to_swp_entry, swp_entry_to_pte,
> swp_entry, I did come to the conclusion that the MAX_SWAPFILES bound
> was actually safely built in there.

I do not think we want anyone go mad so could be simplify this whole m***
so that mere mortals can comprehend what is going on while reading the
source?

> Have you no mercy? Oh, wasn't it rendered safe by the:

Ok. So we have a mystical expression here that needs to be explained:

swp_type(pte_to_swp_entry(swp_entry_to_pte(swp_entry(~0UL,0))))

swp_entry(~0L,0) ->
swp_entry(0xffffffffffffffff, 0) ->
0xfffffffffffffff << SWP_TYPE_SHIFT ->
0x1f

Ok we got the highest swap type and this encodes MAX_SWAPFILES_SHIFT and
therefore limits the number of swap

But now we convert this to a arch specific pte. The hope is that the arch
will mask off any unsupported bits? This is done by s390?

Then we convert the result back into a swap entry and take its type which
will hopefully give us the maximum number of swap devices supported by the
arch?

Would it not be better for an arch to explicitly tell us how many swap
devices are supported? Then we could make the swap_info array shorter and
get rid of this cryptic test.

This test also creates a problem for the migration entries: It is really
not clear until runtime how many swap devices are supported so we cannot
take the last 2 for page migration. In order for page migration to work
all NUMA arches that do not support 32 swap devices need to define
CONFIG_MIGRATION=n. Seems that this is only s390?



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/