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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 8C3DFC4363A for ; Tue, 20 Oct 2020 18:00:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 834D52076A for ; Tue, 20 Oct 2020 18:00:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="P3N/QKgu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 834D52076A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 76C506B005C; Tue, 20 Oct 2020 14:00:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 71C8C6B0062; Tue, 20 Oct 2020 14:00:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E4A26B0068; Tue, 20 Oct 2020 14:00:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0034.hostedemail.com [216.40.44.34]) by kanga.kvack.org (Postfix) with ESMTP id 2FD9B6B005C for ; Tue, 20 Oct 2020 14:00:14 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B0964181AEF0B for ; Tue, 20 Oct 2020 18:00:13 +0000 (UTC) X-FDA: 77393067906.17.bell31_450f28b27241 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 976E5180D0180 for ; Tue, 20 Oct 2020 18:00:13 +0000 (UTC) X-HE-Tag: bell31_450f28b27241 X-Filterd-Recvd-Size: 5504 Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Tue, 20 Oct 2020 18:00:12 +0000 (UTC) Received: by mail-qk1-f195.google.com with SMTP id 188so2350947qkk.12 for ; Tue, 20 Oct 2020 11:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SvI9nFVOm89huMNWCRfBwT5OD9WDOvwN3RZaYD6afks=; b=P3N/QKgurREQ+ofcDVlF/8l+2DCDJjzx0/IdzkZzogfwF2BTLRCtlwVtyrrOif6nEe 3xUGE6lSdiufsOrH4IkLoGN7bXqrgwXle4cC+1QsVJI/0Ye+v3mYp8dAv3SjvcAt9jzM sFmisp2CGKNSVes8HdBPouJRXcKeeRQSjOdvbOxudJdk3lzDPPvh5lXFiYTu9X+Kggk4 qcfH6ELidHELA0eKKNNR9mVZ0umexKv/my+a3dyaR71KQrUEO/IJTRRahyIJFd6izQO9 fo5ztebX0HS+B3K47q9PKApNvl3R52BYnhMQfFqC6olR238Sgozi48l+jmJoJ5vdFFzx nDhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SvI9nFVOm89huMNWCRfBwT5OD9WDOvwN3RZaYD6afks=; b=BLScMC1r3yWcbHTIDuu6xX7UKp7yCycKcd92/AP1Sdvt8jA8pZXvqYQfv9JQLdAOUc rxYHtvmDCGDQ7hpSHW+JhiVlZ3ILyguWyvK3P3IsVTYlmjBgwj2BgZndbHOTPJuMmZJL cXqiqAyIZ/VHtHJmNn1TNkrvblDa6Sm8Q4k0IABpY5sIHRphD81rEpPMIPRx8H5WC32v zpCg3j1ARDi4M+bPXzDuKPuH6CN7ECsVmX5fBK0gNgsnOHIG9OhCU5Dk6pqzx6O69JlO j5RQLGMGuRVzXk8JW+nkmj4tQZOMndLWImJ9BOmtM2eV7uBZtC72kYPiJfgsfzyLL/mB bxmg== X-Gm-Message-State: AOAM533i3flHhL00Zp1L30FUPfk4RqpOsB6PTmxWasuKi5GRB1tcCgt7 YxuYg65r7uEUkFg9EMS8n9x5sA== X-Google-Smtp-Source: ABdhPJwUkrBa1MGge2vrjozAEedOWNjrgytgUIe84AyFVRKo4yzY23tbVNh6JT+4HyJezXLif2ECYg== X-Received: by 2002:a37:a74e:: with SMTP id q75mr2003716qke.277.1603216811818; Tue, 20 Oct 2020 11:00:11 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:c52c]) by smtp.gmail.com with ESMTPSA id j9sm1046697qtk.89.2020.10.20.11.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 11:00:10 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH] mm: don't wake kswapd prematurely when watermark boosting is disabled Date: Tue, 20 Oct 2020 13:58:33 -0400 Message-Id: <20201020175833.397286-1-hannes@cmpxchg.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 2-node NUMA hosts we see bursts of kswapd reclaim and subsequent pressure spikes and stalls from cache refaults while there is plenty of free memory in the system. Usually, kswapd is woken up when all eligible nodes in an allocation are full. But the code related to watermark boosting can wake kswapd on one full node while the other one is mostly empty. This may be justified to fight fragmentation, but is currently unconditionally done whether watermark boosting is occurring or not. In our case, many of our workloads' throughput scales with available memory, and pure utilization is a more tangible concern than trends around longer-term fragmentation. As a result we generally disable watermark boosting. Wake kswapd only woken when watermark boosting is requested. Signed-off-by: Johannes Weiner --- mm/page_alloc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e74ca22baaa1..4f9d9f7e910c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2470,12 +2470,12 @@ static bool can_steal_fallback(unsigned int order= , int start_mt) return false; } =20 -static inline void boost_watermark(struct zone *zone) +static inline bool boost_watermark(struct zone *zone) { unsigned long max_boost; =20 if (!watermark_boost_factor) - return; + return false; /* * Don't bother in zones that are unlikely to produce results. * On small machines, including kdump capture kernels running @@ -2483,7 +2483,7 @@ static inline void boost_watermark(struct zone *zon= e) * memory situation immediately. */ if ((pageblock_nr_pages * 4) > zone_managed_pages(zone)) - return; + return false; =20 max_boost =3D mult_frac(zone->_watermark[WMARK_HIGH], watermark_boost_factor, 10000); @@ -2497,12 +2497,14 @@ static inline void boost_watermark(struct zone *z= one) * boosted watermark resulting in a hang. */ if (!max_boost) - return; + return false; =20 max_boost =3D max(pageblock_nr_pages, max_boost); =20 zone->watermark_boost =3D min(zone->watermark_boost + pageblock_nr_page= s, max_boost); + + return true; } =20 /* @@ -2540,8 +2542,7 @@ static void steal_suitable_fallback(struct zone *zo= ne, struct page *page, * likelihood of future fallbacks. Wake kswapd now as the node * may be balanced overall and kswapd will not wake naturally. */ - boost_watermark(zone); - if (alloc_flags & ALLOC_KSWAPD) + if (boost_watermark(zone) && (alloc_flags & ALLOC_KSWAPD)) set_bit(ZONE_BOOSTED_WATERMARK, &zone->flags); =20 /* We are not allowed to try stealing from the whole block */ --=20 2.28.0