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=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 807C8C35242 for ; Wed, 19 Feb 2020 19:40:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 42106206DB for ; Wed, 19 Feb 2020 19:40:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42106206DB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kerneltoast.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E01246B0003; Wed, 19 Feb 2020 14:40:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB0C06B0006; Wed, 19 Feb 2020 14:40:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC69F6B0007; Wed, 19 Feb 2020 14:40:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0217.hostedemail.com [216.40.44.217]) by kanga.kvack.org (Postfix) with ESMTP id B3FF36B0003 for ; Wed, 19 Feb 2020 14:40:10 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7955B8248047 for ; Wed, 19 Feb 2020 19:40:10 +0000 (UTC) X-FDA: 76507892580.17.net08_1e8b80d29f028 X-HE-Tag: net08_1e8b80d29f028 X-Filterd-Recvd-Size: 4130 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Wed, 19 Feb 2020 19:40:09 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id 6so621573pgk.0 for ; Wed, 19 Feb 2020 11:40:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=xk3FQWFLEA9Ivw7eQtk1E45ebBr0l+OsXJaKdMkwewM=; b=apmCKoLI4jdEnuB3xA1DKhDVuQACjOclrmZK8rrN86plCIIRJUID0fp1Ru63qDwqXM jVQC8Wmsbjf7eGDG5NC6lDzr4fnrLRB8DFRFtQR/wzui9aG+77EAsObkiWMufWWBbexN NB2ChNsBqaak73PYZWZC+TyHTriml3f+pz8CmLS+4rpyS+kUYDRP6NP+b9ROG7CEcDre yGfuqSnzeuwsVnl1HPTrH2ditO9tHnT9cx+lI2KB0qRgIQk9UpI07MzA7gmhgflwvDVt G6kdUbMNnvYR/wK8NDrBzxKnCUqlu5pM2g+hIz9hfX2rj9BOlt6udPJR1wOWQpWG6kEy ituw== X-Gm-Message-State: APjAAAU7zFSX4dGTPRfTJOiK3j2DdTV3Cd2x1eBHd0410ibYEBYVfk26 LmWvPMs0yWQenl85PpSNpiA= X-Google-Smtp-Source: APXvYqw2c5Lr90FnrKjZBh1E37nvLIczFX0XDP5GUvh7AyvJ4X/KbXpJ3bdQxra43uC9r6BfB0duVQ== X-Received: by 2002:a62:486:: with SMTP id 128mr28636963pfe.236.1582141208801; Wed, 19 Feb 2020 11:40:08 -0800 (PST) Received: from sultan-book.localdomain ([104.200.129.62]) by smtp.gmail.com with ESMTPSA id c8sm510530pgq.30.2020.02.19.11.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 11:40:08 -0800 (PST) Date: Wed, 19 Feb 2020 11:40:06 -0800 From: Sultan Alsawaf To: Dave Hansen Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: Stop kswapd early when nothing's waiting for it to free pages Message-ID: <20200219194006.GA3075@sultan-book.localdomain> References: <20200219182522.1960-1-sultan@kerneltoast.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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, Feb 19, 2020 at 11:13:21AM -0800, Dave Hansen wrote: > On 2/19/20 10:25 AM, Sultan Alsawaf wrote: > > Keeping kswapd running when all the failed allocations that invoked it > > are satisfied incurs a high overhead due to unnecessary page eviction > > and writeback, as well as spurious VM pressure events to various > > registered shrinkers. When kswapd doesn't need to work to make an > > allocation succeed anymore, stop it prematurely to save resources. > > But kswapd isn't just to provide memory to waiters. It also serves to > get free memory back up to the high watermark. This seems like it might > result in more frequent allocation stalls and kswapd wakeups, which > consumes extra resources. > > I guess I'd wonder what positive effects you have observed as a result > of this patch and whether you've gone looking for any negative effects. This patch essentially stops kswapd from going overboard when a failed allocation fires up kswapd. Otherwise, when memory pressure is really high, kswapd just chomps through CPU time freeing pages nonstop when it isn't needed. On a constrained system I tested (mem=2G), this patch had the positive effect of improving overall responsiveness at high memory pressure. On systems with more memory I tested (>=4G), kswapd becomes more expensive to run at its higher scan depths, so stopping kswapd prematurely when there aren't any memory allocations waiting for it prevents it from reaching the *really* expensive scan depths and burning through even more resources. Combine a large amount of memory with a slow CPU and the current problematic behavior of kswapd at high memory pressure shows. My personal test scenario for this was an arm64 CPU with a variable amount of memory (up to 4G RAM + 2G swap). Sultan