From patchwork Thu Oct 25 09:44:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10655657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F399109C for ; Thu, 25 Oct 2018 09:45:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EC422B2AC for ; Thu, 25 Oct 2018 09:45:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 214672B2B3; Thu, 25 Oct 2018 09:45:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B961D2B2A0 for ; Thu, 25 Oct 2018 09:45:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA3306B027B; Thu, 25 Oct 2018 05:45:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A29B66B027C; Thu, 25 Oct 2018 05:45:32 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CC236B027D; Thu, 25 Oct 2018 05:45:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 47AB16B027B for ; Thu, 25 Oct 2018 05:45:32 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id 87-v6so6029517pfq.8 for ; Thu, 25 Oct 2018 02:45:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=2667EAPFGGqTW5KmFlUaFOrwPJrjirsBYthOK8nJl3Q=; b=dGPv6jTOENPi/qz7xO3GRWL02EvDBMObTPJ4YgrtAE36Oj0YYvaJqELN71hK4ytMhq PYYfMv7BMSH0bfwEAZ2PpdM3xIxK/vFYLcsM3A5yROigOFxGqFiUV5NX9uQgoY/WANq3 4xwmR/7M9HU5tKYpvxXwRGniOpykKFgBm8NGx8eqxh/eVBPoQtGNwiHkDVtM2PHKtag4 tmyKo9thahcyfo+drfN8ZtvKfICv/tKV+C+FUXKMqpYoajKgXSHqYhGQLpumqyObm/ov 3CifOE3cBwE10xz+QcWKqvyqYgWczpWzsTLu3PUpkseZlyjDdY675O0cgP84e6uBCbFU pnCA== X-Gm-Message-State: AGRZ1gJ3Bn4F+sTRok/XfcKrXwvB0lrTy6p3znqNPLkFfrJ0jblcJDHm zlan+QVGd4N6Pp1jeeW70+40VfBgxT8g+1xwv7bTPG8YL0uaQY0XItu6ZeUl85TEJSQFcZuPvFF aO3/0L5ZYRiH8UtBRlNdCTCod6fw8ZnWEy3tmwbRXD23wNXaiptlPPsSOUPKGWg6QCrcFKj44oq qodWzZ9jm5Mkxcw+MiQFWyC8JQWcWVwcmSMQ5QGZq/bULXOCqlCLUUWJ1SwajXAQz5IGE6Q8Bnr /wcVecOe2z5snm+8Z8kaE0Rui1YL3ts0wCUYdgB/L4qSRn0V2qcg//8m9wZY0VPaPAmbuuvz/41 7parLF+XpUrKZ/BibUsS5lv+LMw45eF1SmFL9CckTvIVpKfpvCVzMpL5eGfzHZ8iDgtaVjh4AxD I X-Received: by 2002:a17:902:5982:: with SMTP id p2-v6mr808979pli.241.1540460731977; Thu, 25 Oct 2018 02:45:31 -0700 (PDT) X-Received: by 2002:a17:902:5982:: with SMTP id p2-v6mr808948pli.241.1540460731050; Thu, 25 Oct 2018 02:45:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540460731; cv=none; d=google.com; s=arc-20160816; b=sgx8NdwbX4eJL12VaNM3IT2glE7ns8V3h9jYpGpvjJ1GoT6BwQqmTor3PGsiEnZW+X Et3A9oys/gehodJKrqf2BxiL14nVrcksja580wEeoOfdMINa2M/qH74U6nAHiX+DIPmf MVh6YOpLyX3rVY96nlU3f8Tz/66qpZ1weFHXFr7EHEe6kZkXxFzbswBWXHPeE27htL0W az3mJUSWprlWCMH1+rnXT10kCc1bJ5WRqABp+ulQONSaW8SuDBXXzN/JRiH0+91WiMUB 7G+sebQ4LecKiamYLXn9b9yjgNMZP7kQUM6/Xxe7g37zkXxkA9eLVWwKfnjdSsw9TWvv 3nuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=2667EAPFGGqTW5KmFlUaFOrwPJrjirsBYthOK8nJl3Q=; b=zeHKC8Wu3rmyRdXwDLjhtcr9WDtFACMoY9Z9MptpYhVKpltsfezXijUE1YdFq1EmTB TSbSfi8i2/OMspVy66RKrYOqkjXKF0OJJYNWi2zVUU/EgD8+s87LrReXCKLLsXlz2chO rlhLlHdCQlHtxq1vKT7Om141O7y4xfEfEvbitc+VvL8oNr8zvzdHxYMaATORxl84LyeG EEdMd2DNBVlNdcarzfNmncVNam57fC+ZwMbEzKVBPo0dvxpek9u7QgpkNay5/6NgJOiE s8etFsMt71Y+wAg0gGgo5lYt0Rmhmljb6nxxBx5JKgMXWje4qvwsAk7aS84Spd1MYTan z8Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=u6ddFhkn; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z31-v6sor2926595plb.35.2018.10.25.02.45.30 for (Google Transport Security); Thu, 25 Oct 2018 02:45:31 -0700 (PDT) Received-SPF: pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=u6ddFhkn; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2667EAPFGGqTW5KmFlUaFOrwPJrjirsBYthOK8nJl3Q=; b=u6ddFhknEbr6O26sDoUcDaaLMfeq3OaPL/an0a25WLT6Gc3lxgxFjgSKWXdJaS7IWB Cqx3fAuqsytnUTDPdzC0ijpDkJkqdGUPv+2Sx4jCGCAez17x0mvrJlhIYnnGOsyt0u1T SJ5Y19A3MN08bimV4DA/WqBgkzk+KhPWxDVCXIBrcagcv6CVbfOeFuXWA1tKHzCkqdxl xvnXGlV/bSRlpREH3Cqo5f/kEmGMDNdyJ8fkXlsegayqVMZ8mjHNrqmu+K1sE+ZFye/n 1M3LCy33iDBTAX2nZc/eVCWT0MdqOexLIfXRnHJ9n0LJ45mL6GSdAEUtMjvStlG+hm1Y 7ZLg== X-Google-Smtp-Source: AJdET5eJpFzOQ38HVB6XiievhXQaU6kAI/iIYbM4hngRNIaBrJQYXPh/ybpQtnTOu092YKjMbwUKWA== X-Received: by 2002:a17:902:6b04:: with SMTP id o4-v6mr809449plk.333.1540460730407; Thu, 25 Oct 2018 02:45:30 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id u190-v6sm28858049pgu.3.2018.10.25.02.45.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Oct 2018 02:45:29 -0700 (PDT) From: Wei Yang To: cl@linux.com, penberg@kernel.org, rientjes@google.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, Wei Yang Subject: [PATCH 1/3] mm, slub: not retrieve cpu_slub again in new_slab_objects() Date: Thu, 25 Oct 2018 17:44:35 +0800 Message-Id: <20181025094437.18951-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP In current code, the following context always meets: local_irq_save/disable() ___slab_alloc() new_slab_objects() local_irq_restore/enable() This context ensures cpu will continue running until it finish this job before yield its control, which means the cpu_slab retrieved in new_slab_objects() is the same as passed in. Signed-off-by: Wei Yang --- mm/slub.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index ce2b9e5cea77..11e49d95e0ac 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2402,10 +2402,9 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid) } static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags, - int node, struct kmem_cache_cpu **pc) + int node, struct kmem_cache_cpu *c) { void *freelist; - struct kmem_cache_cpu *c = *pc; struct page *page; WARN_ON_ONCE(s->ctor && (flags & __GFP_ZERO)); @@ -2417,7 +2416,6 @@ static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags, page = new_slab(s, flags, node); if (page) { - c = raw_cpu_ptr(s->cpu_slab); if (c->page) flush_slab(s, c); @@ -2430,7 +2428,6 @@ static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags, stat(s, ALLOC_SLAB); c->page = page; - *pc = c; } else freelist = NULL; @@ -2567,7 +2564,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, goto redo; } - freelist = new_slab_objects(s, gfpflags, node, &c); + freelist = new_slab_objects(s, gfpflags, node, c); if (unlikely(!freelist)) { slab_out_of_memory(s, gfpflags, node);