Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1313904ybx; Tue, 5 Nov 2019 14:04:45 -0800 (PST) X-Google-Smtp-Source: APXvYqwq/blJTeVfd1LT4AWYg3jWtBdKYXOunZ40rCc/6rlXBq+Lek9mjz3jQK8C1TUmXy+TPf1l X-Received: by 2002:aa7:c2c7:: with SMTP id m7mr12833671edp.295.1572991485398; Tue, 05 Nov 2019 14:04:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572991485; cv=none; d=google.com; s=arc-20160816; b=OQS+TkgfSrQ9G7WvzQnZq6AEp1P/iAa5oHrxinZyOtzb4iBO1PORq/ZRZ4TmQ5/h6u gwky8GdD4npszPoNXQ8gO0D0jSHh2ZKS8jYrCQ7vfgReoXxF7WnC35Rf9tWJUnLO9QTY TbJbOfovNc++ElV2sJOOwkMehe5phdBDpoomwkfVI+/Tte9tmjVgT1o5KxA6YWB2kOhn 6/BC/F4xHknqDeVH3bqgQ9BQolmNAG11MF+9EATZYAWz/VMWOa61sq5QNYf2t1B1jOBN /8evUq1DbXJzaAInb8MYvTU+KxIaZkpK7bN6ClIOsoCpv09uZSZVxtbze1miFt6Q2kyl WLFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=lalRbIANsAQDLeciC8gLUIN+yz+EonKfMCCxU39jeWk=; b=jAjX8U3lXpLXEOVr9WmlVERr/D8P2rGySldw1dEXLKc75C9fRHS8veRceoiezv4+V+ IefdF8FGS78m5x8XYLnc6rdJUIS2EnbkfV5iTAenAxiIzxaM5LQIwKnmzHp50dWAFvyF wqd0mh78NzOaVY2y9YH9JJUnAKnleWoTyGVlKFNNUv0PswkkjwfLpTUA8unIxVd64/Vm aXIHn5fubcta7vgb32j4h8HCgQFqsJP2LZPOCyUjifUzkA1M2jK1XtGof2O8SSyN29nl yre3eMk9usVUq7P9DqfoGBrqDBJXYdb3ZmQMgZVQ0QtS6VOqogEKj6CUNJTurm2rR5Qm HQGA== 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=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g21si10806068ejs.171.2019.11.05.14.04.20; Tue, 05 Nov 2019 14:04:45 -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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729970AbfKEWCl (ORCPT + 99 others); Tue, 5 Nov 2019 17:02:41 -0500 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:52663 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387510AbfKEWCk (ORCPT ); Tue, 5 Nov 2019 17:02:40 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01419;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0ThIYtiy_1572991352; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0ThIYtiy_1572991352) by smtp.aliyun-inc.com(127.0.0.1); Wed, 06 Nov 2019 06:02:38 +0800 From: Yang Shi To: hughd@google.com, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: shmem: use proper gfp flags for shmem_writepage() Date: Wed, 6 Nov 2019 06:02:31 +0800 Message-Id: <1572991351-86061-1-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. In addition, XArray node allocations from PF_MEMALLOC contexts could completely exhaust the page allocator, __GFP_NOMEMALLOC stops emergency reserves from being allocated. 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