Re: [PATCH 5/7] rust: file: add `Kuid` wrapper

From: Matthew Wilcox
Date: Fri Dec 08 2023 - 15:43:54 EST


On Fri, Dec 08, 2023 at 09:08:47AM -0800, Nick Desaulniers wrote:
> From a build system perspective, I'd rather just point users towards
> LTO if they have this concern. We support full and thin lto. This
> proposal would add a third variant for just rust drivers. Each
> variation on LTO has a maintenance cost and each have had their own
> distinct fun bugs in the past. Not sure an additional variant is
> worth the maintenance cost, even if it's technically feasible.

If we're allowed to talk about ideal solutions ... I hate putting
code in header files. I'd rather be able to put, eg:

__force_inline int put_page_testzero(struct page *page)
{
VM_BUG_ON_PAGE(page_ref_count(page) == 0, page);
return page_ref_dec_and_test(page);
}

__force_inline int folio_put_testzero(struct folio *folio)
{
return put_page_testzero(&folio->page);
}

__force_inline void folio_put(struct folio *folio)
{
if (folio_put_testzero(folio))
__folio_put(folio);
}

into a .c file and have both C and Rust inline folio_put(),
folio_put_testzero(), put_page_testzero(), VM_BUG_ON_PAGE() and
page_ref_dec_and_test(), but not even attempt to inline __folio_put()
(because We Know Better, and have determined that is the point at
which to stop).