From: Patrick Farrell Date: Thu, 28 Sep 2023 00:09:03 +0000 (-0400) Subject: LU-10026 ptlrpc: verify large allocations are aligned X-Git-Tag: 2.16.56~22 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=4c972aa6696a50ddfbc0dcb3e8db36f4b435fa4e;p=fs%2Flustre-release.git LU-10026 ptlrpc: verify large allocations are aligned If we were ever to do an allocation with kmalloc(), we could get non-page-aligned memory. We haven't seen any problem yet, but we are trying to be ready for this in advance. The arguments from https://lwn.net/Articles/787740/ also look strong. Let's add an assertion to illuminate this dangerous behaviour. EX-bug-id: EX-8245 Signed-off-by: Patrick Farrell Signed-off-by: Artem Blagodarenko Change-Id: Id20898065b516d363d9dc280e71be1b5cfb6f4a7 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57844 Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Reviewed-by: Sergey Cheremencev Tested-by: Maloo Tested-by: jenkins --- diff --git a/lustre/obdclass/page_pools.c b/lustre/obdclass/page_pools.c index edc4b0b..34d8695 100644 --- a/lustre/obdclass/page_pools.c +++ b/lustre/obdclass/page_pools.c @@ -569,6 +569,18 @@ static int pool_add_objects(int nobjects, struct obd_page_pool *page_pool) else { OBD_ALLOC_LARGE(ptr_pages[i][j], object_size(page_pool)); + /* + * It is possible that at some moment kmalloc + * will start to return non-page aligned memory, + * so leave this assort for quicker problem + * detection + */ + LASSERTF(IS_ALIGNED((unsigned long) + (ptr_pages[i][j]), + PAGE_SIZE), + "Page %p (order %i) is not aligned to PAGE_SIZE", + ptr_pages[i][j], page_pool->opp_order); + } if (ptr_pages[i][j] == NULL) goto out_ptr_pages;