From patchwork Sun Nov 25 23:58:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yang X-Patchwork-Id: 10697199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29FC413BF for ; Sun, 25 Nov 2018 23:55:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 095EA293E4 for ; Sun, 25 Nov 2018 23:55:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3E7F294E8; Sun, 25 Nov 2018 23:55:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B05EF293E4 for ; Sun, 25 Nov 2018 23:55:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6811D6B3ECB; Sun, 25 Nov 2018 18:55:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 606C36B3ECC; Sun, 25 Nov 2018 18:55:40 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4802E6B3ECD; Sun, 25 Nov 2018 18:55:40 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 0329E6B3ECB for ; Sun, 25 Nov 2018 18:55:40 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id ay11so19670413plb.20 for ; Sun, 25 Nov 2018 15:55:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=8e7E7ITWT1VN5QpnjNxebPkq/K1dd8D7jhUafpSEV8I=; b=Q114FyCY9AE2RFsH11GRPzzeogLjzrWKx10qZWh81xJfq5s7BMfebmjuj7JjWYNKJ7 x+Gg0GNqBQ1vPUKOo6p4lC1W/62yIdYVF7iomFqIuG3leGZdka12Oy0qm06QVI3VX2k4 CL94fEFo/YZJRPawlbdrHcL1AWb54NQeYHpUV26527XsE5bfJWhm/JcOPcgixm0gbjSD 7PKK6nWQDQa6jOfdZWeK61jtVlIPLyges1/oHhLtcQNjKWXgqw62NhtMpxAcImjJuwat QpXNGSHFqzQrFI5YkRoRY0b9Pc2dhTKkZat1A2ha2ztNpIuUN53SzqzFD/7G6495Hhhf TlPg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.yang29@zte.com.cn designates 63.217.80.70 as permitted sender) smtp.mailfrom=yang.yang29@zte.com.cn X-Gm-Message-State: AA+aEWZN9WsTVcIzZLklMHXX8yq3s3kaJX9cPDbqppWBzroK+EPATGuv I4Y0QMFqKCXBIn9Liu0J+NsCGvRNTSVX+p9lCrcuHwrsTdO/Ac4SSCHEX8UYIlee0NZ6t8Q/bgl X5idehESUJJ7Vos0brrItG5l5uS5WwsmgLZPTVDWYWNizs1OUCfe9fKAmyigZBqob+w== X-Received: by 2002:a63:200e:: with SMTP id g14mr22618356pgg.235.1543190139646; Sun, 25 Nov 2018 15:55:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/WSl8DlIWki3cWDyw37kOUqD0LZLvXup8s4PMkjXiwK+OK3mpYSAOJsvhyI8gya6MMadVJz X-Received: by 2002:a63:200e:: with SMTP id g14mr22618325pgg.235.1543190138503; Sun, 25 Nov 2018 15:55:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543190138; cv=none; d=google.com; s=arc-20160816; b=GqKUR+UMGyNT36Gmc4w6tcalS+q2NP3vX757UBRltUBEkZ2ME+5U0ZvwCQXqhy2S0b EhJaiBydg5PqcODiR20qEQYkhZpIYRzg4JXhgSkY/rsJHnzHpf/s8ErFnjMDfGIcMR40 XJ5ya7ZOe7N1cjnsFzZzMy+ML8rhMVWp7goGhq5VTcaRASTcJm27JB1y+lEUhlNzHNW+ E7oLL+00+XaJE3qRR1fnsBam/tB0vBcS+OINM4qqgZWbt2woXW+oiVffS3+brezJOBL3 ShQSp7ZXZeoRo4uN158VVBOtUM55nGcKWH1F8WgNhQjzBlCeR/O4GXJ8gpdOPkw6ugLq rloQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=8e7E7ITWT1VN5QpnjNxebPkq/K1dd8D7jhUafpSEV8I=; b=ekQQ5d0LY4ErQnCOcCLU2GLR8dPfZitOFlfLpVkP9SI+AJXpthosWMnyvKJcgfzmMC Yhyvc6EzP1nPLlXPxVAcyb39SguSdZxMFLtBLA/jmQlqGSaBRBfHn10YKs+CNEFwQb3R VkUQuoUGWl+oHqENRdJBKU/vVwUQQkN43IV3PGRqLfBqclAUvwzIJRPUDA3NUku+Snn3 gPLsd2GgDJ9OirIFB0bYAE2wYF7OZL7F0vXOI8DpEWyTA6AZCHqRk+hE/vul01Ab4g3h L/tCP64S7dVYeSn5sUVokFYLGIyyq3GseRqt8jhyiUE+NqnIVjqaDGyzRjFfa/Yb+mKo eKZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.yang29@zte.com.cn designates 63.217.80.70 as permitted sender) smtp.mailfrom=yang.yang29@zte.com.cn Received: from mxhk.zte.com.cn (mxhk.zte.com.cn. [63.217.80.70]) by mx.google.com with ESMTPS id k189si2757709pgd.589.2018.11.25.15.55.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 15:55:38 -0800 (PST) Received-SPF: pass (google.com: domain of yang.yang29@zte.com.cn designates 63.217.80.70 as permitted sender) client-ip=63.217.80.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.yang29@zte.com.cn designates 63.217.80.70 as permitted sender) smtp.mailfrom=yang.yang29@zte.com.cn Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 65F923A9DBB2370909C9; Mon, 26 Nov 2018 07:55:36 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id wAPNtVEx093301; Mon, 26 Nov 2018 07:55:31 +0800 (GMT-8) (envelope-from yang.yang29@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018112607553337-12876764 ; Mon, 26 Nov 2018 07:55:33 +0800 From: Yang Yang To: akpm@linux-foundation.org Cc: mhocko@suse.com, pavel.tatashin@microsoft.com, vbabka@suse.cz, osalvador@suse.de, rppt@linux.vnet.ibm.com, iamjoonsoo.kim@lge.com, alexander.h.duyck@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn, wang.yi59@zte.com.cn, Yang Yang Subject: [PATCH] mm: do not consider SWAP to calculate available when not necessary Date: Mon, 26 Nov 2018 07:58:23 +0800 Message-Id: <1543190303-8121-1-git-send-email-yang.yang29@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-11-26 07:55:33, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-11-26 07:55:30, Serialize complete at 2018-11-26 07:55:30 X-MAIL: mse01.zte.com.cn wAPNtVEx093301 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: X-Virus-Scanned: ClamAV using ClamSMTP When si_mem_available() calculates 'available', it takes SWAP into account. But if CONFIG_SWAP is N or SWAP is off(some embedded system would like to do that), there is no need to consider it. Signed-off-by: Yang Yang --- mm/page_alloc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6847177..10e186b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4700,6 +4700,7 @@ static inline void show_node(struct zone *zone) long si_mem_available(void) { + struct sysinfo i; long available; unsigned long pagecache; unsigned long wmark_low = 0; @@ -4708,6 +4709,7 @@ long si_mem_available(void) struct zone *zone; int lru; + si_swapinfo(&i); for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++) pages[lru] = global_node_page_state(NR_LRU_BASE + lru); @@ -4724,9 +4726,13 @@ long si_mem_available(void) * Not all the page cache can be freed, otherwise the system will * start swapping. Assume at least half of the page cache, or the * low watermark worth of cache, needs to stay. + * But if CONFIG_SWAP is N or SWAP is off, do not consider it. */ pagecache = pages[LRU_ACTIVE_FILE] + pages[LRU_INACTIVE_FILE]; - pagecache -= min(pagecache / 2, wmark_low); +#ifdef CONFIG_SWAP + if (i.totalswap > 0) + pagecache -= min(pagecache / 2, wmark_low); +#endif available += pagecache; /*