2024-04-26 16:22:30

by David Howells

[permalink] [raw]
Subject: Re: [PATCH net] rxrpc: Fix using alignmask being zero for __page_frag_alloc_align()

Yunsheng Lin <[email protected]> wrote:

> rxrpc_alloc_data_txbuf() may be called with data_align being
> zero in none_alloc_txbuf() and rxkad_alloc_txbuf(), data_align
> is supposed to be an order-based alignment value, but zero is
> not a valid order-based alignment value

Ummm... 0 *would be* a valid order-based[*] alignment (pow(2,0) is 1). It
might actually make more sense to do that than to pass in the number of bytes,
then 0 is the default, but either way works.

[*] Other places that take an order-based parameter include things like
alloc_pages(). The number of pages being requested is pow(2,order).

> + return rxrpc_alloc_data_txbuf(call, min_t(size_t, remain, RXRPC_JUMBO_DATALEN), 1U, gfp);
> + return rxrpc_alloc_data_txbuf(call, space, 1U, gfp);

The 'U' should be unnecessary.

> + data_align = max_t(size_t, data_align, L1_CACHE_BYTES);

data_align = umax(data_align, L1_CACHE_BYTES);

would be better, I think.

Anyway, with the umax change above:

Acked-by: David Howells <[email protected]>