linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Rich Felker <dalias@libc.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Linux-sh list <linux-sh@vger.kernel.org>,
	Rob Landley <rob@landley.net>,
	Linux-Arch <linux-arch@vger.kernel.org>,
	Matt Fleming <matt@codeblueprint.co.uk>
Subject: Re: [PATCH] sh: remove unneeded constructor.
Date: Wed, 1 Aug 2018 19:47:59 -0700	[thread overview]
Message-ID: <20180802024759.GB25338@bombadil.infradead.org> (raw)
In-Reply-To: <20180801230205.GI1392@brightrain.aerifal.cx>

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<<PTE_MAGNITUDE),
+                                      PAGE_SIZE, SLAB_PANIC, pgd_ctor);

+pgd_t *pgd_alloc(struct mm_struct *mm)
+{
+       return kmem_cache_alloc(pgd_cachep, PGALLOC_GFP);

It clearly doesn't cause any bugs to zero the PGD entries (... or somebody
would have noticed since 2009?), but I suspect it causes various PMD
entries to not be shared.

I'm really happy we decided to introduce this check.  It caught a really
old and completely unrelated bug!

      reply	other threads:[~2018-08-02  4:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180731051519.101249-1-ysato@users.sourceforge.jp>
2018-08-01  7:42 ` [PATCH] sh: remove unneeded constructor Geert Uytterhoeven
2018-08-01 11:13   ` Yoshinori Sato
2018-08-04 10:35     ` Matthew Wilcox
2018-08-04 10:47       ` Geert Uytterhoeven
2018-08-04 10:51         ` Matthew Wilcox
2018-08-05 15:54           ` Rob Landley
2018-08-05 16:32             ` Rich Felker
2018-08-05 22:48               ` Rob Landley
2018-08-05 23:33                 ` Rich Felker
2018-08-06  6:57                   ` Geert Uytterhoeven
2018-08-06  8:53                     ` Arnd Bergmann
2018-08-10 18:18                     ` Rob Landley
2020-06-06 16:32           ` Rich Felker
2020-06-06 16:32             ` Rich Felker
2020-06-08 13:01             ` Matthew Wilcox
2020-06-08 13:01               ` Matthew Wilcox
2018-08-01 11:20   ` Matthew Wilcox
2018-08-01 23:02     ` Rich Felker
2018-08-02  2:47       ` Matthew Wilcox [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=20180802024759.GB25338@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=dalias@libc.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=matt@codeblueprint.co.uk \
    --cc=rob@landley.net \
    --cc=ysato@users.sourceforge.jp \
    /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;
as well as URLs for NNTP newsgroup(s).