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, 10 Jul 2015 15:32:35 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc:	Johannes Weiner <hannes@...xchg.org>,
	Minchan Kim <minchan@...nel.org>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Subject: Re: [RFC] mm/shrinker: define INIT_SHRINKER macro

On Fri, 10 Jul 2015 10:12:11 +0900 Sergey Senozhatsky <sergey.senozhatsky.work@...il.com> wrote:

> Shrinker API does not handle nicely unregister_shrinker() on a not-registered
> ->shrinker. Looking at shrinker users, they all have to (a) carry on some sort
> of a flag telling that "unregister_shrinker()" will not blow up... or (b) just
> be fishy
> 
> ...
>
> 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".

> --- a/include/linux/shrinker.h
> +++ b/include/linux/shrinker.h
> @@ -63,6 +63,12 @@ struct shrinker {
>  };
>  #define DEFAULT_SEEKS 2 /* A good number if you don't know better. */
>  
> +#define INIT_SHRINKER(s) 			\
> +	do {					\
> +		INIT_LIST_HEAD(&(s)->list);	\
> +		(s)->nr_deferred = NULL;	\
> +	} while (0)
> +

The only reason to make this a macro would be so that it can be used at
compile-time, with something like

static struct shrinker my_shrinker = INIT_SHRINKER(&my_shrinker);

But as we're not planning on doing that, we implement it in C, please.

Also, shrinker_init() would be a better name.  Although we already
mucked up shrinker_register() and shrinker_unregister().


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ