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=-8.5 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 2DB84C5DF63 for ; Wed, 6 Nov 2019 15:18:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E9E852166E for ; Wed, 6 Nov 2019 15:18:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9E852166E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 80A096B0006; Wed, 6 Nov 2019 10:18:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B9DF6B0007; Wed, 6 Nov 2019 10:18:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CF7F6B0008; Wed, 6 Nov 2019 10:18:23 -0500 (EST) 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 582706B0006 for ; Wed, 6 Nov 2019 10:18:23 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 1D4198249980 for ; Wed, 6 Nov 2019 15:18:23 +0000 (UTC) X-FDA: 76126208886.19.gun37_492747cc7f92a X-HE-Tag: gun37_492747cc7f92a X-Filterd-Recvd-Size: 2598 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 Nov 2019 15:18:22 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 58B34AB9D; Wed, 6 Nov 2019 15:18:21 +0000 (UTC) Date: Wed, 6 Nov 2019 16:18:20 +0100 From: Michal Hocko To: Yang Shi Cc: hughd@google.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: shmem: use proper gfp flags for shmem_writepage() Message-ID: <20191106151820.GB8138@dhcp22.suse.cz> References: <1572991351-86061-1-git-send-email-yang.shi@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1572991351-86061-1-git-send-email-yang.shi@linux.alibaba.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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: On Wed 06-11-19 06:02:31, Yang Shi wrote: > The shmem_writepage() uses GFP_ATOMIC to allocate swap cache. > GFP_ATOMIC used to mean __GFP_HIGH, but now it means __GFP_HIGH | > __GFP_ATOMIC | __GFP_KSWAPD_RECLAIM. However, shmem_writepage() should > write out to swap only in response to memory pressure, so > __GFP_KSWAPD_RECLAIM looks useless since the caller may be kswapd itself > or in direct reclaim already. What kind of problem are you trying to fix here? > In addition, XArray node allocations from PF_MEMALLOC contexts could > completely exhaust the page allocator, __GFP_NOMEMALLOC stops emergency > reserves from being allocated. I am not really familiar with XArray much, could you be more specific please? > Here just copy the gfp flags used by add_to_swap(). > > Cc: Hugh Dickins > Signed-off-by: Yang Shi > --- > mm/shmem.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/shmem.c b/mm/shmem.c > index 220be9f..9691dec 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -1369,7 +1369,8 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) > if (list_empty(&info->swaplist)) > list_add(&info->swaplist, &shmem_swaplist); > > - if (add_to_swap_cache(page, swap, GFP_ATOMIC) == 0) { > + if (add_to_swap_cache(page, swap, > + __GFP_HIGH | __GFP_NOMEMALLOC | __GFP_NOWARN) == 0) { > spin_lock_irq(&info->lock); > shmem_recalc_inode(inode); > info->swapped++; > -- > 1.8.3.1 -- Michal Hocko SUSE Labs