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:   Fri, 19 Mar 2021 16:39:41 +0300
From:   Dmitry Osipenko <digetx@...il.com>
To:     Minchan Kim <minchan@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-mm <linux-mm@...ck.org>, LKML <linux-kernel@...r.kernel.org>,
        joaodias@...gle.com, willy@...radead.org, david@...hat.com,
        surenb@...gle.com, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        John Hubbard <jhubbard@...dia.com>,
        Nicolas Chauvet <kwizart@...il.com>,
        "linux-tegra@...r.kernel.org" <linux-tegra@...r.kernel.org>
Subject: Re: [PATCH v4] mm: cma: support sysfs

19.03.2021 15:44, Dmitry Osipenko пишет:
...
>>  #include <linux/debugfs.h>
>> +#include <linux/kobject.h>
>> +
>> +struct cma_stat {
>> +	spinlock_t lock;
>> +	/* the number of CMA page successful allocations */
>> +	unsigned long nr_pages_succeeded;
>> +	/* the number of CMA page allocation failures */
>> +	unsigned long nr_pages_failed;
>> +	struct kobject kobj;
>> +};
>>  
>>  struct cma {
>>  	unsigned long   base_pfn;
>> @@ -16,6 +26,9 @@ struct cma {
>>  	struct debugfs_u32_array dfs_bitmap;
>>  #endif
>>  	char name[CMA_MAX_NAME];
>> +#ifdef CONFIG_CMA_SYSFS
>> +	struct cma_stat	*stat;
>> +#endif

What is the point of allocating stat dynamically?

...
>> +void cma_sysfs_alloc_pages_count(struct cma *cma, size_t count)
>> +{
>> +	spin_lock(&cma->stat->lock);
>> +	cma->stat->nr_pages_succeeded += count;
>> +	spin_unlock(&cma->stat->lock);
>> +}
>> +
>> +void cma_sysfs_fail_pages_count(struct cma *cma, size_t count)
>> +{
>> +	spin_lock(&cma->stat->lock);
>> +	cma->stat->nr_pages_failed += count;
>> +	spin_unlock(&cma->stat->lock);
>> +}

You could use atomic increment and then locking isn't needed.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ