From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Minchan Kim <minchan@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] mm/shrinker: define INIT_SHRINKER macro
Date: Sat, 11 Jul 2015 10:48:12 +0900 [thread overview]
Message-ID: <20150711014812.GD811@swordfish> (raw)
In-Reply-To: <20150710183357.30605207.akpm@linux-foundation.org>
On (07/10/15 18:33), Andrew Morton wrote:
> > > > I was thinking of a trivial INIT_SHRINKER macro to init `struct shrinker'
> > > > internal members (composed in email client, not tested)
> > > >
> > > > include/linux/shrinker.h
> > > >
> > > > #define INIT_SHRINKER(s) \
> > > > do { \
> > > > (s)->nr_deferred = NULL; \
> > > > INIT_LIST_HEAD(&(s)->list); \
> > > > } while (0)
> > >
> > > Spose so. Although it would be simpler to change unregister_shrinker()
> > > to bale out if list.next==NULL and then say "all zeroes is the
> > > initialized state".
> >
> > Yes, or '->nr_deferred == NULL' -- we can't have NULL ->nr_deferred
> > in a properly registered shrinker (as of now)
>
> list.next seems safer because that will always be non-zero. But
> whatever - we can change it later.
>
> > But that will not work if someone has accidentally passed not zeroed
> > out pointer to unregister.
>
> I wouldn't worry about that really. If you pass a pointer to
> uninitialized memory, the kernel will explode. That's true of just
> about every pointer-accepting function in the kernel.
>
True. But with shrinker it's hard to say whether we have a properly
initialized shrinker embedded in our `struct foo' or we don't (unless
we treat register_shrinker() errors as a show stopper) by simply looking at
shrinker struct (w/o touching it's private members). In zsmalloc, for
instance, we don't consider failed register_shrinker() to be critical
enough to forbid zs_pool creation and usage. It makes things harder later
in zs_destroy_pool(), because we need to carry some sort of flag for that
purpose. But `list.next' check in unregister_shrinker() would suffice in
zsmalloc case, I must admit, because we kzalloc() the entire zs_pool
struct.
-ss
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2015-07-11 1:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-10 1:12 Sergey Senozhatsky
2015-07-10 22:32 ` Andrew Morton
2015-07-11 1:25 ` Sergey Senozhatsky
2015-07-11 1:33 ` Andrew Morton
2015-07-11 1:48 ` Sergey Senozhatsky [this message]
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=20150711014812.GD811@swordfish \
--to=sergey.senozhatsky@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=sergey.senozhatsky.work@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox