From: Dmitry Osipenko <digetx@gmail.com>
To: Minchan Kim <minchan@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
joaodias@google.com, willy@infradead.org, david@redhat.com,
surenb@google.com,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
John Hubbard <jhubbard@nvidia.com>,
Nicolas Chauvet <kwizart@gmail.com>,
"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH v4] mm: cma: support sysfs
Date: Fri, 19 Mar 2021 16:45:57 +0300 [thread overview]
Message-ID: <8d7ae527-e0ff-6fa9-7ba3-899a75abc3fa@gmail.com> (raw)
In-Reply-To: <e8ae901d-9521-8de4-ee45-18cb55b8f29c@gmail.com>
19.03.2021 16:39, Dmitry Osipenko пишет:
> 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.
>
Actually, the counter should be u64 in order not to worry about overflow.
next prev parent reply other threads:[~2021-03-19 13:46 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-09 6:23 [PATCH v4] mm: cma: support sysfs Minchan Kim
2021-03-19 12:44 ` Dmitry Osipenko
2021-03-19 13:39 ` Dmitry Osipenko
2021-03-19 13:42 ` Greg Kroah-Hartman
2021-03-19 13:45 ` Dmitry Osipenko
2021-03-19 13:47 ` Greg Kroah-Hartman
2021-03-19 13:51 ` Dmitry Osipenko
2021-03-19 14:19 ` Dmitry Osipenko
2021-03-19 14:27 ` Greg Kroah-Hartman
2021-03-19 15:38 ` Dmitry Osipenko
2021-03-19 15:50 ` Greg Kroah-Hartman
2021-03-19 16:24 ` Dmitry Osipenko
2021-03-19 16:30 ` Minchan Kim
2021-03-19 17:29 ` Dmitry Osipenko
2021-03-19 17:41 ` Dmitry Osipenko
2021-03-19 17:44 ` Dmitry Osipenko
2021-03-19 18:07 ` Matthew Wilcox
2021-03-19 18:18 ` Minchan Kim
2021-03-19 18:59 ` Dmitry Osipenko
2021-03-19 19:00 ` Dmitry Osipenko
2021-03-19 17:56 ` Dmitry Osipenko
2021-03-19 18:21 ` Minchan Kim
2021-03-19 18:48 ` Dmitry Osipenko
2021-03-19 19:03 ` Minchan Kim
2021-03-19 19:24 ` Dmitry Osipenko
2021-03-20 7:52 ` Greg Kroah-Hartman
2021-03-22 14:44 ` Dmitry Osipenko
2021-03-19 13:45 ` Dmitry Osipenko [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-03-04 16:17 Minchan Kim
2021-03-05 17:34 ` David Hildenbrand
2021-03-05 20:34 ` Minchan Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8d7ae527-e0ff-6fa9-7ba3-899a75abc3fa@gmail.com \
--to=digetx@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=jhubbard@nvidia.com \
--cc=joaodias@google.com \
--cc=kwizart@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-tegra@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=surenb@google.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.