Re: [PATCH v3 23/59] netfs: Prep to use folio->private for write grouping and streaming write

Matthew Wilcox
2023-12-07T21:36:05Z

On Thu, Dec 07, 2023 at 09:21:30PM +0000, David Howells wrote:
> +#define NETFS_FOLIO_INFO 0x1UL /* OR'd with folio->private. */
> +
> +static inline struct netfs_folio *netfs_folio_info(struct folio *folio)
> +{
> + void *priv = folio_get_private(folio);
> +
> + if ((unsigned long)priv & NETFS_FOLIO_INFO)
> + return (struct netfs_folio *)((unsigned long)priv & ~NETFS_FOLIO_INFO);

Often one gets better code by using '-' instead of '& ~', and that's
because 'subtract one, then load four bytes from offset 12' can be
optimised into 'load four bytes from offset 11' in a way that 'clear
the bottom bit, then load four bytes from offset 12' can't be.