From patchwork Wed Sep 26 06:52:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 10615337 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 309C015A6 for ; Wed, 26 Sep 2018 06:52:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20FB22A61D for ; Wed, 26 Sep 2018 06:52:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14A7C2A625; Wed, 26 Sep 2018 06:52:26 +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 580672A61D for ; Wed, 26 Sep 2018 06:52:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 441638E0002; Wed, 26 Sep 2018 02:52:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3F14D8E0001; Wed, 26 Sep 2018 02:52:24 -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 3075D8E0002; Wed, 26 Sep 2018 02:52:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id E5BD38E0001 for ; Wed, 26 Sep 2018 02:52:23 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id w18-v6so10276710plp.3 for ; Tue, 25 Sep 2018 23:52:23 -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=CxCIMWQ9OvAHT+YR+T3f6Yu1idSXkAHI5FBu8KhcBVA=; b=jloaYR3uMoRftejicDVQ+IoO6ywlOh86oA+XrHAIbdHduq9Xf6NFtZNYNJUnKsptAJ mA2fFb0zRkJY0BppvY5U3pqt0OC/el3s5hsn+XZ0brKOjdAH3ioygQCR7yhT1d23umhM 5ZsNodVc25pmkWrxh1o1yhzYKcaYb0CodIq7URCFG2VMai7RKdcqcfWhSkLfCwZgfSQF AL67lp4SakUYj268oS/ZMa2usf2DilClXCEJanwyW8X53pcOm5CGj5r8GG3gMxlRe8p2 6ECrw8zvHyJA8+TpnEXyTtofVjio/jfLHTV1lhuJeB4RWWHcLAdfhoaU3PJn0RSrGact RNTA== X-Gm-Message-State: ABuFfojMN8VHpQOWfrt+9gZa0YqJTvwulg1GDdwf+Kz9q1JSYLcqL5X0 SVqadzX6hf1HLI9x+Pijh0YObpbJ45/t1MzUVzW+Ps+Xgtgv5RM4Y2Y4+ZLuYYE7a7Jlp9thVGE hI1o1kjpJyqC1/w628Ryxv0CcdgW6tYWmjHMRHoy17wH/MHWAnqADgiIqDr8ncDFgu8kaXqg1jJ nO5yJNhTTqqEmD6LsrjrejN0vDUzzXPyx7M7djQMhIP/3FEA+aOwX/8gX9/8zQsBBcIP/36m3Hg w12PlA7NJgCfDJCIGIRZeMqV29evyRAvMTwOb2mw2aYwgcuY925r3urhT93Uk5/ClP/rzWvsuIb os/ISAsRpmrZyn0jT63HM1pHUdEt+gauntGUtfB39YXv5YrNtcJq3Z2JnYghYOM1+nMQ4OSKC+E Z X-Received: by 2002:a63:f043:: with SMTP id s3-v6mr4177105pgj.94.1537944743555; Tue, 25 Sep 2018 23:52:23 -0700 (PDT) X-Received: by 2002:a63:f043:: with SMTP id s3-v6mr4177049pgj.94.1537944742583; Tue, 25 Sep 2018 23:52:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537944742; cv=none; d=google.com; s=arc-20160816; b=zxqXfkRERk+5vVX/1pDZxOWlZqOWeFkIXttWVylag/PuDUXhJIQAN0SLp2e+qDxNl+ pbf+Dloutv43PMy0vn+SrxtbJfoXP0cHn1Gu3QvtkkywRSt0TA4o8x74Ff/pm8feqnhx U22H0zYGFHkyuaHefY1V94EFU0G63dEpDLwdiqpEfuJtEm9sIB6N5h0Pv+KwTs9skMXR p1t5/2VakjDjWk3yOlhNWnWc6RxjAjm1gy9L5HjGhA71Pkp4Fjuphw7cvUzDf/ufV8iw UvHEZ5wGWzTYQjw7UsKVPn5ZEtpjF/6Gxw/36g3UObusu3rmS4o32hTPBqBBMgQrlN+W qk9g== 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=CxCIMWQ9OvAHT+YR+T3f6Yu1idSXkAHI5FBu8KhcBVA=; b=K65VtuIvgQgjQ6+2cc+C8+xtCG8l7bLhWkv9gy00jqMEWOaZqRk3dRHJ/0eDeyK+89 9k7ssZDQcApacw4MZj3zDxmqQZc56u7txrhJJYGDAUhW/08bYve9mgGtZ6g0Rqxlpl5y 0lF8QDLRQsqVyq33OJv75mUe5oa0knzuU7WCc/lZSopvi7qjSghhSP7wqLcRT6z/9ARG k/kYskE0NdzWw2rD3jCpKTqvMP9wbX4XvwfyY4isyCQbWMLSoxKvwJS6gKLIHd05oXZI BNjaRsj+Xp9bSSbJzsOjIHG8gs5bsquyHkfEd9G3vNG+mhdsm/+OzNoKKBagHhmcKirl 1YXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Xfj2vkNi; spf=pass (google.com: domain of kernelfans@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=kernelfans@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 x7-v6sor609359pgt.392.2018.09.25.23.52.22 for (Google Transport Security); Tue, 25 Sep 2018 23:52:22 -0700 (PDT) Received-SPF: pass (google.com: domain of kernelfans@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=Xfj2vkNi; spf=pass (google.com: domain of kernelfans@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=kernelfans@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=CxCIMWQ9OvAHT+YR+T3f6Yu1idSXkAHI5FBu8KhcBVA=; b=Xfj2vkNiMrhZplJ8Bdo271gr/IYe4iN5l9peU01VZB9cm3lN4+puPZHRiHpO9k2Yay vSXBp1VjbN2SaWAGvMCWnwtalT0Rmsybgm6/yf99iAbzLohUe1Fjzt6FShJr/3bT0wh0 nrdhx6aQJMVoUH7o1S9oixXm720gpd/G1qzp9sEal+09peKgJHjZ6F01K8GVCiWRRO2o D0a8J3RQlMqaXoESDeoINj4X+j1WyYZzgO5vVI8tEXHPVbclbf10z1fhOJGrsE/Twg5T x7Hh10YKx+1ZThuz8XhN5TmiE2tzVO80QEa+Ppsm25J2uBqVqYQ1vocrxwVUnJmU8lVv FZ1Q== X-Google-Smtp-Source: ACcGV61B/nZPr5G2z0WXU4ZUuDftAMweT0r/5Cn21RqudDEY5M72JffMlZSnElgESLR6ixZeURh75w== X-Received: by 2002:a63:2a0b:: with SMTP id q11-v6mr4193970pgq.36.1537944741861; Tue, 25 Sep 2018 23:52:21 -0700 (PDT) Received: from mylaptop.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id e3-v6sm5666521pgc.71.2018.09.25.23.52.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 23:52:20 -0700 (PDT) From: Pingfan Liu To: linux-mm@kvack.org Cc: Pingfan Liu , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton Subject: [PATCH] mm/slub: disallow obj's allocation on page with mismatched pfmemalloc purpose Date: Wed, 26 Sep 2018 14:52:08 +0800 Message-Id: <1537944728-18036-1-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 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 new_slab_objects() always return c->page matching the required gfpflags, but the current code is misleading and ___slab_alloc->deactivate_slab seems to allow not-pfmemalloc purpose obj to be allocated from pfmemalloc-purpose page. This patch re-organize the code to eliminate the confusion. Signed-off-by: Pingfan Liu Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton --- mm/slub.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index a68c2ae..e152634 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2551,23 +2551,21 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, } freelist = new_slab_objects(s, gfpflags, node, &c); - if (unlikely(!freelist)) { slab_out_of_memory(s, gfpflags, node); return NULL; } + VM_BUG_ON(!pfmemalloc_match(page, gfpflags)); page = c->page; - if (likely(!kmem_cache_debug(s) && pfmemalloc_match(page, gfpflags))) + if (likely(!kmem_cache_debug(s)) goto load_freelist; /* Only entered in the debug case */ - if (kmem_cache_debug(s) && - !alloc_debug_processing(s, page, freelist, addr)) + if (!alloc_debug_processing(s, page, freelist, addr)) goto new_slab; /* Slab failed checks. Next slab needed */ - - deactivate_slab(s, page, get_freepointer(s, freelist), c); - return freelist; + else + goto load_freelist; } /*