lkml.org 
[lkml]   [2022]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v7 04/14] mm/shmem: Support memfile_notifier
From
On 06.07.22 10:20, Chao Peng wrote:
> From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
>
> Implement shmem as a memfile_notifier backing store. Essentially it
> interacts with the memfile_notifier feature flags for userspace
> access/page migration/page reclaiming and implements the necessary
> memfile_backing_store callbacks.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
> ---

[...]

> +#ifdef CONFIG_MEMFILE_NOTIFIER
> +static struct memfile_node *shmem_lookup_memfile_node(struct file *file)
> +{
> + struct inode *inode = file_inode(file);
> +
> + if (!shmem_mapping(inode->i_mapping))
> + return NULL;
> +
> + return &SHMEM_I(inode)->memfile_node;
> +}
> +
> +
> +static int shmem_get_pfn(struct file *file, pgoff_t offset, pfn_t *pfn,
> + int *order)
> +{
> + struct page *page;
> + int ret;
> +
> + ret = shmem_getpage(file_inode(file), offset, &page, SGP_WRITE);
> + if (ret)
> + return ret;
> +
> + unlock_page(page);
> + *pfn = page_to_pfn_t(page);
> + *order = thp_order(compound_head(page));
> + return 0;
> +}
> +
> +static void shmem_put_pfn(pfn_t pfn)
> +{
> + struct page *page = pfn_t_to_page(pfn);
> +
> + if (!page)
> + return;
> +
> + put_page(page);


Why do we export shmem_get_pfn/shmem_put_pfn and not simply

get_folio()

and let the caller deal with putting the folio? What's the reason to

a) Operate on PFNs and not folios
b) Have these get/put semantics?

> +}
> +
> +static struct memfile_backing_store shmem_backing_store = {
> + .lookup_memfile_node = shmem_lookup_memfile_node,
> + .get_pfn = shmem_get_pfn,
> + .put_pfn = shmem_put_pfn,
> +};
> +#endif /* CONFIG_MEMFILE_NOTIFIER */
> +
> void __init shmem_init(void)
> {
> int error;
> @@ -3956,6 +4059,10 @@ void __init shmem_init(void)
> else
> shmem_huge = SHMEM_HUGE_NEVER; /* just in case it was patched */
> #endif
> +
> +#ifdef CONFIG_MEMFILE_NOTIFIER
> + memfile_register_backing_store(&shmem_backing_store);

Can we instead prove a dummy function that does nothing without
CONFIG_MEMFILE_NOTIFIER?

> +#endif
> return;
>
> out1:


--
Thanks,

David / dhildenb

\
 
 \ /
  Last update: 2022-08-05 15:26    [W:0.926 / U:0.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site