Received: by 2002:a05:6a10:87d6:0:0:0:0 with SMTP id g22csp755087pxr; Mon, 11 Apr 2022 06:29:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG1xlU6EJmSXB1zYSAPAopFH4WyXnJM+81Wxk2/fp3BQqYQCPwSPoLv1UaqDUxrMCTSSex X-Received: by 2002:aa7:db0f:0:b0:41d:7b44:2613 with SMTP id t15-20020aa7db0f000000b0041d7b442613mr4860091eds.126.1649683789248; Mon, 11 Apr 2022 06:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649683789; cv=none; d=google.com; s=arc-20160816; b=qXDdLUcG/snnw4WHh4aaWJ5+R+ABXu5KDd4mu+9lWb05RMoOFjFbBmRGAoKxtMzfuS YEyqEW+FFbgootZRNrgmu6e6BBCxO2FAvD3bakJlF5k79ZPZRj81cjBGL+cDB4WbJtmY ORYQcBIv3lDSezT93uoSFslOSS+zOeTpue7D29KwcCyO+WeguBH/rekid02YBA7ClJEk PPIERUsVdq9bljsCFHeE3Y9/KQbtE2mnlNL6cipTTYCpL7CLZrbuJPFAhsFDoNsx4nT0 x4S3C01zlN3EEqhBmhxYribhuqJHEGiAOp+7mkbmSCDWj3RzZhniLD2gH2IRWOYPzdUk kzAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9QPhopgx/tgVvIztmP4VR/uXXXoVW1IfZx4Olt9pjko=; b=mr9DX00N5mF7AxITpaFI1f8YmBJZSyIpXKZn2nLKqe6XPTIwnKsRj/OrTxTaOgQWaU YEAkkJYXyb47b/BmTBQDj55moNRTnxHDih/0brNtzeN0a+Nm/WakCodeMctvgJV2nZ82 ALDDXk2Y6NEjTt/Wlv/cQVRSVruNyGeHj+2uF/chrLXGC2LQcFVdkMzA6w1745+KzRMK 09euk8ZgRI4sweH6x3o8MPkIA55bD8vRtkbiQ+Cniyb7B6Q46aJGHwjRj1rurA6DXCWY 22n+nofQpdJPTpttDNVFndbIjFJbuSCpmMek+mmYAjnSstmbi6LZgk7IVwdbdWAGFvON BhKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LIEb0aa1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u3-20020a50eac3000000b00418c2b5bd56si6950809edp.56.2022.04.11.06.29.23; Mon, 11 Apr 2022 06:29:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LIEb0aa1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243566AbiDJQPg (ORCPT + 99 others); Sun, 10 Apr 2022 12:15:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233003AbiDJQPd (ORCPT ); Sun, 10 Apr 2022 12:15:33 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29AB45E77F for ; Sun, 10 Apr 2022 09:13:23 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id a16-20020a17090a6d9000b001c7d6c1bb13so14282558pjk.4 for ; Sun, 10 Apr 2022 09:13:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9QPhopgx/tgVvIztmP4VR/uXXXoVW1IfZx4Olt9pjko=; b=LIEb0aa1C5AYGxvqnI4eGbxRFwdHsQXgihBa/z7HEdPflb2+iivTS/Zlm2VuZ6Ib6U aqy7mVQy3o8Khe/ieIsgwbrjzF8CaSxZaVRQEcZ5Yc4jHgQQDCbDNkQTSLi7hnqOgegg Zurdmqo7e8QXOyXAhZw53isHJuC9QtT1kXbTSzhXaL1zzZBLDJDuQf0dU73wT5b8yUq8 MNWQPpsD+4tRBhEEGQrgA0K4bRXxqpF4+QFPiqMLCGEumjYwhK0EagFi5WAG5FsopgTW kdPi2ZImksJ400qth9VAYLO+ytJmnu+u8kE3JPdMxYwuwFYGvWvqNroyh7JzhOg5gb2w 4/HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9QPhopgx/tgVvIztmP4VR/uXXXoVW1IfZx4Olt9pjko=; b=JTcbNMby5QkVKA4tTjD4fuZO0chIf1AiMM8Vfpe0Lojr5WcpJ7fPIdPuovDaPELiDh UnU65CILiSarR88YUYJ4Wswnzr6O9NbU1KS2RAkn1rBzKjN6F5OllXq47kvplWDoSedL UrS9jazTG7GPLh7q6m8yFUnnUUKcJsddYEKJaPTNyJ7vD1PTZg8pYcBzs9uB5USkXuj+ vgQdUeS+TOI+a/8wuE9Rtv6JCn7vTvHUbiTlORQYnCE0ADG257OFiphpTgdKImJyAgOl 56HwN+EXiTjvpCzx21Z6PDS/Fh0pkp39XRXPhFVDrEZTALlaYlFY2M4Et5nIQgA8gNQQ iSpQ== X-Gm-Message-State: AOAM532Sg9c1gsWcGh4jT4YJLbRnX5BR6GRHRwbvr9nPm0bsJqhnFHaT YU/myx3MDOZ+3wVW2SXy9byTwn09YrgQudXCfjU= X-Received: by 2002:a17:902:ce04:b0:156:3be:8a86 with SMTP id k4-20020a170902ce0400b0015603be8a86mr29417688plg.152.1649607202565; Sun, 10 Apr 2022 09:13:22 -0700 (PDT) MIME-Version: 1.0 References: <20220409160224.611353-1-ohkwon1043@gmail.com> In-Reply-To: From: Ohoon Kwon Date: Mon, 11 Apr 2022 01:13:11 +0900 Message-ID: Subject: Re: [PATCH] mm/slub: check pfmemalloc_match in slab_alloc_node fastpath To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , JaeSang Yoo , Wonhyuk Yang , Jiyoup Kim , Donghyeok Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Oh I was not aware of those histories. I checked the commits, and it seems it is better to leave it optimized(as it is now). Thanks for your help. Ohhoon Kwon. On Sun, Apr 10, 2022 at 5:12 PM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: > > On Sun, Apr 10, 2022 at 01:02:23AM +0900, Ohhoon Kwon wrote: > > If current alloc context does not have __GFP_MEMALLOC in its gfpflags, > > then slab objects that were previously created with __GFP_MEMALLOC > > should not be given. > > > > This criteria is well kept in slab alloc slowpath: > > When gfpflags does not contain __GFP_MEMALLOC but if per-cpu slab page > > was allocated with __GFP_MEMALLOC, then allocator first deactivates > > per-cpu slab page and then again allocates new slab page with the > > current context's gfpflags. > > > > However, this criteria is not checked in fastpath. > > It should also be checked in the fastpath, too. > > > > Signed-off-by: Ohhoon Kwon > > --- > > mm/slub.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/mm/slub.c b/mm/slub.c > > index 74d92aa4a3a2..c77cd548e106 100644 > > --- a/mm/slub.c > > +++ b/mm/slub.c > > @@ -3179,7 +3179,8 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s, struct list_l > > * there is a suitable cpu freelist. > > */ > > if (IS_ENABLED(CONFIG_PREEMPT_RT) || > > - unlikely(!object || !slab || !node_match(slab, node))) { > > + unlikely(!object || !slab || !node_match(slab, node) || > > + !pfmemalloc_match(slab, gfpflags))) { > > object = __slab_alloc(s, gfpflags, node, addr, c); > > } else { > > void *next_object = get_freepointer_safe(s, object); > > The missing pfmemalloc check in fastpath was intended. > > pfmemalloc check in fast did exist in Mel's commit 072bb0aa5e0629 ("mm: > sl[au]b: add knowledge of PFMEMALLOC reserve pages"). > > But later removed by Christoph's commit 5091b74a95d4 ("mm: slub: optimise > the SLUB fast path to avoid pfmemalloc checks"). > > Any thoughts? > > Thanks! > > -- > Thanks, > Hyeonggon