Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5160393imu; Sun, 25 Nov 2018 18:03:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wra5qmkEzvIHKU/qfy0jo3enc++rz7UTk80hZopJxsmqbna4H0JFXDHxwA1ppRgEu7TGh5 X-Received: by 2002:a63:e156:: with SMTP id h22mr23114547pgk.255.1543197816294; Sun, 25 Nov 2018 18:03:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543197816; cv=none; d=google.com; s=arc-20160816; b=JIgktQStba1xJa9Cmts+1ObfpsZp1AYozZ3Wv4iyewidSTAl09FHCJrRa/jQ8u7Y5x ClZS3NWP8IosdZ+TJOAK9qIvzBU3jtU3R6Gquwy+ulMzbcNleUsxW+GN+KuOI+3nbw7R sgB/e3gDZG1nf+s034jiY9C+SO3mfzeNSIJdElfm3XyT40gEFpaPCJJUeHtJIGj6kM6R kmyI7Y07YNCWfjjxYuDrZAcLiLpoah1aPrRnVwethT5+7VLkQNtFb8r74qwURhACrN8f hHAetebNlUKUndXmBOj+on5mPj2R1qJSAK+lT8IUt/fZ2Wr043MLcwTn1LM9HFqjnBmB LPxA== 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:dkim-signature; bh=jVXu2rkN7izqGpeeBbFryL6jaoCRC7xAik2JpopgPk8=; b=uK7EBJwBZyYc+KUCM1xLe1dSpc3dSw5P+tFYn9s4vWe6IhIzNMirpVqZsZFnjAIBBF JOTF5aelZUDBEsTB6tCLywFCmunlRaElgzvuDbXX741WuykVfrsG7b73Xx3Hu97JL1BE uTqmwoTzing/qrT0hqlqvfgLwuPjPf8PrvbMnttSeWfdAnTpDz9JaE6jKCj4ZaTzapV8 4b1lFmDpIOwZ1ALwgGJy9qeRFcgTo59T3Tb3a/tFyoc6BkkKwyT1ODKWPyLMwb5J4g4V E488RJBRotVi8SsaWGFo+bgTIMfkGBNsuJpAEjUDzJe+cD33nA9q8dgSA0TSoJkCVgcq 1JQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="FNKQ6In/"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d16si20268122pfn.169.2018.11.25.18.03.21; Sun, 25 Nov 2018 18:03:36 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="FNKQ6In/"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726228AbeKZMyB (ORCPT + 99 others); Mon, 26 Nov 2018 07:54:01 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:42090 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726079AbeKZMyB (ORCPT ); Mon, 26 Nov 2018 07:54:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jVXu2rkN7izqGpeeBbFryL6jaoCRC7xAik2JpopgPk8=; b=FNKQ6In/3dxfmKfHi4/fd+f1E DpyjypuQp6Sq792nk4N3v16ZjtCCKvTzRA7Fy8mg0OyUAgA3ew6MpwA1G9Szly3li0NpSseqbYwil XFm6RKYKhhu8fcHQgr6xdvRAGq+g6VdpNmUnxovp8MFJE00TPq0jvC088CP3SgmekKfjG8A7MN6f3 4YuNq40VBed4B/XsYqs6dy6LHQW5wtIw6yKuPmn7EHiQZEo1biRtgnZokHUgKlNmgTJ2UQ3K6pERG 8GS3GdAjiocTs9dl5KBarGBd0r+MDcWqiYQ9lG6DdmCE32DuusdEHqKHSvkNScHQaM8TYGoxmwSei O3yA5RGqQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gR6D5-0005hj-KK; Mon, 26 Nov 2018 02:01:15 +0000 Date: Sun, 25 Nov 2018 18:01:15 -0800 From: Matthew Wilcox To: Yang Yang Cc: akpm@linux-foundation.org, 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 Subject: Re: [PATCH] mm: do not consider SWAP to calculate available when not necessary Message-ID: <20181126020115.GF3065@bombadil.infradead.org> References: <1543190303-8121-1-git-send-email-yang.yang29@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1543190303-8121-1-git-send-email-yang.yang29@zte.com.cn> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 26, 2018 at 07:58:23AM +0800, Yang Yang wrote: > 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. I don't understand this patch. The pagecache can be written back to storage if it is dirty, regardless of whether there is swap space. > @@ -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; > > /* > -- > 2.15.2 >