lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 3 Apr 2023 15:43:32 +0200
From:   Vlastimil Babka <vbabka@...e.cz>
To:     "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
        Borislav Petkov <bp@...en8.de>,
        Andy Lutomirski <luto@...nel.org>,
        Sean Christopherson <seanjc@...gle.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Joerg Roedel <jroedel@...e.de>,
        Ard Biesheuvel <ardb@...nel.org>
Cc:     Andi Kleen <ak@...ux.intel.com>,
        Kuppuswamy Sathyanarayanan 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>,
        David Rientjes <rientjes@...gle.com>,
        Tom Lendacky <thomas.lendacky@....com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Peter Zijlstra <peterz@...radead.org>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Ingo Molnar <mingo@...hat.com>,
        Dario Faggioli <dfaggioli@...e.com>,
        Dave Hansen <dave.hansen@...el.com>,
        Mike Rapoport <rppt@...nel.org>,
        David Hildenbrand <david@...hat.com>,
        Mel Gorman <mgorman@...hsingularity.net>,
        marcelo.cerri@...onical.com, tim.gardner@...onical.com,
        khalid.elmously@...onical.com, philip.cox@...onical.com,
        aarcange@...hat.com, peterx@...hat.com, x86@...nel.org,
        linux-mm@...ck.org, linux-coco@...ts.linux.dev,
        linux-efi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCHv9 04/14] mm/page_alloc: Add sysfs handle to accept
 accept_memory

On 3/30/23 13:49, Kirill A. Shutemov wrote:
> Write amount of memory to accept into the new sysfs handle
> /sys/kernel/mm/page_alloc/accept_memory.
> 
> Write 'all' to the handle to accept all memory in the system.
> 
> It can be used to implement background memory accepting from userspace.
> It is also useful for debugging.
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>

Somewhat similarly to patch 3, I'd think we don't need this patch in
mainline without clear usecases first, although it's good to post for
testing/debugging.

> ---
>  mm/page_alloc.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 64 insertions(+)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 509a93b7e5af..07e16e9b49c4 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -7343,6 +7343,45 @@ static bool __free_unaccepted(struct page *page)
>  	return true;
>  }
>  
> +static ssize_t accept_memory_store(struct kobject *kobj,
> +				    struct kobj_attribute *attr,
> +				    const char *buf, size_t count)
> +{
> +	unsigned long to_accept = 0;
> +	struct zone *zone;
> +	char *retptr;
> +
> +	if (sysfs_streq(buf, "all")) {
> +		to_accept = ULONG_MAX;
> +	} else {
> +		to_accept = memparse(buf, &retptr);
> +
> +		/* Get rid of trailing whitespace, including '\n' */
> +		retptr = skip_spaces(retptr);
> +
> +		if (*retptr != 0 || to_accept == 0)
> +			return -EINVAL;
> +	}
> +
> +	for_each_populated_zone(zone) {
> +		while (try_to_accept_memory_one(zone)) {
> +			if (to_accept <= PAGE_SIZE << MAX_ORDER)
> +				return count;
> +
> +			to_accept -= PAGE_SIZE << MAX_ORDER;
> +		}
> +	}
> +
> +	return count;
> +}
> +
> +static struct kobj_attribute accept_memory_attr = __ATTR_WO(accept_memory);
> +
> +static struct attribute *page_alloc_attr[] = {
> +	&accept_memory_attr.attr,
> +	NULL
> +};
> +
>  #else
>  
>  static bool page_contains_unaccepted(struct page *page, unsigned int order)
> @@ -7366,3 +7405,28 @@ static bool __free_unaccepted(struct page *page)
>  }
>  
>  #endif /* CONFIG_UNACCEPTED_MEMORY */
> +
> +static const struct attribute_group page_alloc_attr_group = {
> +#ifdef CONFIG_UNACCEPTED_MEMORY
> +	.attrs = page_alloc_attr,
> +#endif
> +};
> +
> +static int __init page_alloc_init_sysfs(void)
> +{
> +	struct kobject *page_alloc_kobj;
> +	int err;
> +
> +	page_alloc_kobj = kobject_create_and_add("page_alloc", mm_kobj);
> +	if (!page_alloc_kobj)
> +		return -ENOMEM;
> +
> +	err = sysfs_create_group(page_alloc_kobj, &page_alloc_attr_group);
> +	if (err) {
> +		kobject_put(page_alloc_kobj);
> +		return err;
> +	}
> +
> +	return 0;
> +}
> +late_initcall(page_alloc_init_sysfs);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ