From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Date: Thu, 02 Aug 2018 02:47:59 +0000 Subject: Re: [PATCH] sh: remove unneeded constructor. Message-Id: <20180802024759.GB25338@bombadil.infradead.org> List-Id: References: <20180731051519.101249-1-ysato@users.sourceforge.jp> <20180801112019.GA2666@bombadil.infradead.org> <20180801230205.GI1392@brightrain.aerifal.cx> In-Reply-To: <20180801230205.GI1392@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Rich Felker Cc: Geert Uytterhoeven , Yoshinori Sato , Linux-sh list , Rob Landley , Linux-Arch , Matt Fleming On Wed, Aug 01, 2018 at 07:02:05PM -0400, Rich Felker wrote: > On Wed, Aug 01, 2018 at 04:20:19AM -0700, Matthew Wilcox wrote: > > __GFP_ZERO overrode the constructor. That is, before 128227e7fe40, > > if you specified both a constructor and __GFP_ZERO, first the slab > > code would invoke the constructor, then it would zero the allocation. > > So this patch is preserving the existing behaviour. Whether the existing > > behaviour is correct or not, I cannot say. > > Then I think we should really try to figure out whether this is a > buried bug before deleting the evidence of it... Archaeology suggests the bug was introduced in commit 2a5eacca85d3 ("sh: Move page table allocation out of line") in 2009. Previous code: - pgd = kzalloc(sizeof(*pgd) * PTRS_PER_PGD, GFP_KERNEL | __GFP_REPEAT); - - for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) - pgd[i] = swapper_pg_dir[i]; Replacement code: +#define PGALLOC_GFP GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO +void pgd_ctor(void *x) +{ + pgd_t *pgd = x; + + memcpy(pgd + USER_PTRS_PER_PGD, + swapper_pg_dir + USER_PTRS_PER_PGD, + (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t)); +} + pgd_cachep = kmem_cache_create("pgd_cache", + PTRS_PER_PGD * (1<