From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F3FEC433E3 for ; Fri, 17 Jul 2020 09:14:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3CCC020684 for ; Fri, 17 Jul 2020 09:14:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TQheRHn1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CCC020684 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DFDDE8D0027; Fri, 17 Jul 2020 05:14:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD3D06B006C; Fri, 17 Jul 2020 05:14:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9C128D0027; Fri, 17 Jul 2020 05:14:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id B24066B0062 for ; Fri, 17 Jul 2020 05:14:34 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 723DE18346301 for ; Fri, 17 Jul 2020 09:14:34 +0000 (UTC) X-FDA: 77047007268.10.note01_4b0b04926f09 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 7330832073 for ; Fri, 17 Jul 2020 09:14:26 +0000 (UTC) X-HE-Tag: note01_4b0b04926f09 X-Filterd-Recvd-Size: 4848 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Fri, 17 Jul 2020 09:14:25 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id z63so8119278qkb.8 for ; Fri, 17 Jul 2020 02:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=TTah83XUjnFYRYk4+z1WzNDw5yUiECajFe5/YPDgJlc=; b=TQheRHn1cXzAuyeAdVJtG46D6J951Kk4qGPQR2X703/XXvKFQrxQ5YJZpo8d0xYzfA G1Ghdb7LaYEqxJkZO+RLdKrzPdfnQ43SnF9QgXLfe/odBI6RU7CpT7+hAzjoLxDWUJPE taRBvSd/PXI3ypGn1mKESnLFG6nTFmfYRafYZGCGYfYtOVoJjwB9krtehBjwWXbre8m6 sEnA90M7w/zCaf3qrS530VXFdciyuBxBx9IXXX17qBpYVAkTaPhQwguTSTWNlAegbnVP x07Hacdjp0FdkYy3TCxXSj+flKd3GJhCX8lWfQolxLCNiKb2+RrMgrnlhTgoomzxCs8O g15w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=TTah83XUjnFYRYk4+z1WzNDw5yUiECajFe5/YPDgJlc=; b=TWqazLy6OEPICY4ZQN5dEN0C8lNQW5cvy90cBM+7Obl4Ql7Abx1TQZE8wBz4mAvvPW dfppV6hdZmAFoUkndMf4veFqtmpT/se+fDgvdEcVat9SXSJ+bR7tLj6dP0muNSkUNJIF Z6Mdb+GYd/VmL03I73pwblRAk/hcKdjfO81PgYzEsRiu87TwCmxpv6pDinLzlfFuoLri yJlAy9jVCcQgEsApaQX2ITQ31TcQuKJ+lg3FHYoMaDzMhUHuzeFQxFeyONpsvzC/tR+o PLjuQYI+SQ2QeDnIK3KZf9/E4zgSVWeDKBuaMk6bpmMoScMdqOA/QmgYD5UjwRBhnhed b2pg== X-Gm-Message-State: AOAM533e7EFEfIP3vEsgF/mMqf+l4qAXqnLxVyIJKZf7jQ2f+rmOeKpT MiJaLqgHaX8oIe2dLeSml9p/sSBbr1FspcWsHOs= X-Google-Smtp-Source: ABdhPJxvM0u07hwrbNojbkX69s729/X1zvnefAfZ7a28oA6/z8xgZwIufAPfsMk3UtbX7ynthXdoomYlrLvjC7Mvhw8= X-Received: by 2002:a37:6d2:: with SMTP id 201mr7473861qkg.187.1594977265463; Fri, 17 Jul 2020 02:14:25 -0700 (PDT) MIME-Version: 1.0 References: <1594789529-6206-1-git-send-email-iamjoonsoo.kim@lge.com> In-Reply-To: From: Joonsoo Kim Date: Fri, 17 Jul 2020 18:14:14 +0900 Message-ID: Subject: Re: [PATCH 1/4] mm/page_alloc: fix non cma alloc context To: David Laight Cc: Andrew Morton , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "kernel-team@lge.com" , Vlastimil Babka , Christoph Hellwig , Roman Gushchin , Mike Kravetz , Naoya Horiguchi , Michal Hocko , "Aneesh Kumar K . V" , Joonsoo Kim , "stable@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 7330832073 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: 2020=EB=85=84 7=EC=9B=94 17=EC=9D=BC (=EA=B8=88) =EC=98=A4=ED=9B=84 5:32, D= avid Laight =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > From: js1304@gmail.com > > Sent: 15 July 2020 06:05 > > From: Joonsoo Kim > > > > Currently, preventing cma area in page allocation is implemented by usi= ng > > current_gfp_context(). However, there are two problems of this > > implementation. > ... > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 6416d08..cd53894 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > ... > > @@ -3693,6 +3691,16 @@ alloc_flags_nofragment(struct zone *zone, gfp_t = gfp_mask) > > return alloc_flags; > > } > > > > +static inline void current_alloc_flags(gfp_t gfp_mask, > > + unsigned int *alloc_flags) > > +{ > > + unsigned int pflags =3D READ_ONCE(current->flags); > > + > > + if (!(pflags & PF_MEMALLOC_NOCMA) && > > + gfp_migratetype(gfp_mask) =3D=3D MIGRATE_MOVABLE) > > + *alloc_flags |=3D ALLOC_CMA; > > +} > > + > > I'd guess this would be easier to understand and probably generate > better code if renamed and used as: > alloc_flags |=3D can_alloc_cma(gpf_mask); > > Given it is a 'static inline' the compiler might end up > generating the same code. > If you needed to clear a flag doing: > alloc_flags =3D current_alloc_flags(gpf_mask, alloc_flags); > is much better for non-inlined function. Vlastimil suggested this way and I have agreed with that. Anyway, thanks for the suggestion. Thanks.