Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp712985ybx; Wed, 6 Nov 2019 07:20:16 -0800 (PST) X-Google-Smtp-Source: APXvYqzflTqx2X0B4v62ykmX040RO0NU0gddjoX4mpoe7vMALW2ReiwlKkyFzuJ6Qbl7nXNQZzwZ X-Received: by 2002:a05:6402:1692:: with SMTP id a18mr3273699edv.297.1573053616658; Wed, 06 Nov 2019 07:20:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573053616; cv=none; d=google.com; s=arc-20160816; b=wlgz01SXaazlzryWvRd+UWhB1YL1lRicsTtCOef/4lBuQ/NFLurUPavxQs9zl+65X/ i9Nc81XF7vNX8nNkO1JGnKpROOBvchEF5wBkm2ZeMvRUdk9GJKFVw23iDJY93zEaNqNa a21k2GgBkSObwcQh1dBd7OU2j3Iztedd65ecbYu1rBGzZKEzNr7Ln4U2Uh+1FMrCFJph ZFCALy9oZmy4Q+QlG3JoQM6J7U0S0v6J3HPZMVXCQFeFkCnN/Jpyaj/VywjKMcpoFC8Q nai5+mQjpRKHg4MJTlzUKZm2oNIv9K8SHH4cCTgZ07YX3ZXzEeYRgNqis8rn51M1cdHp +lVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=S4Uym5cZwz986c/FZkbSUP3ctet6uk9Oqd4hdvtdCyg=; b=gVc8FjvMLMpAMvObXvHpCrsVHA5MDLIHtsogJBF/fqkL+TrhNoQHp3+Q24fkiKl2Hd 33gOBK+Hz+LlmnDTRO0NgtT4Wx7eE7KauXReow9F0BF5zlabP/Nkb9wJq28GKarepakn tQcDylPtqubNFsEClnoy+waPw1vnBM8xc1XfJB97md94ofdWpzdoLIZuEDVjLfMdkDkO f7OKIPD7nQ7Hixqt+5xonLDvxq5OuEBbx5lKcUuN8WqSb8/gC+99P9OH+/R9PJP59/El eL+2zCpfF05o0RvX6QbPKIYitAEvGCLKyG2vi1uJgO2Rptgn/+ebFlqSoLylNJTJAvXL 2llA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si12783936edz.83.2019.11.06.07.19.52; Wed, 06 Nov 2019 07:20:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731826AbfKFPSX (ORCPT + 99 others); Wed, 6 Nov 2019 10:18:23 -0500 Received: from mx2.suse.de ([195.135.220.15]:47272 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727231AbfKFPSW (ORCPT ); Wed, 6 Nov 2019 10:18:22 -0500 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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