Re: [RFC] mm/shrinker: define INIT_SHRINKER macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 11 Jul 2015 10:25:13 +0900 Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx> 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.


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]