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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6476EC77B7D for ; Sat, 13 May 2023 10:27:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CCEAF6B0071; Sat, 13 May 2023 06:27:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7D3C6B0072; Sat, 13 May 2023 06:27:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6BC46B0074; Sat, 13 May 2023 06:27:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A4FAD6B0071 for ; Sat, 13 May 2023 06:27:13 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5D5B016106E for ; Sat, 13 May 2023 10:27:13 +0000 (UTC) X-FDA: 80784854346.02.D1B7FD8 Received: from outbound-smtp43.blacknight.com (outbound-smtp43.blacknight.com [46.22.139.229]) by imf22.hostedemail.com (Postfix) with ESMTP id 46215C000A for ; Sat, 13 May 2023 10:27:09 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf22.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.229 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683973630; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fY383+Gla1alV1ijFpf8NT2XSOf72L3VMK0kwJE5Nbs=; b=XFO1vNl7jS2CGUHYJGQTeF7gqtcOrCup6aXIRORiw6xzZCvPNCbnPdzYtrOsMNw0BJj1Yh yIxA8ZVj1ipajawki5rwlT838CYpvfS7JdUjgT5LOkzjBwqyQ7Gf3qrmTN1cQYSs3UDudF LCm79x7yM+dGM5fNb2C5yx6F/Egp5Sg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683973630; a=rsa-sha256; cv=none; b=O3Y1DgtXnDuKBt+VHzMU2KBf2Fjg6yTfWHqz0hUzqv3EKRh792Lx9SJwmFpB65GVPJ9zh+ GNyitceNHjWitKXVE7nVwNwSW9Sg454XPbDWcTYXBI1zRpex1x03usosgD9a/gwZz9l82S 7uA+94oUi/3uiGpqt5GtmL1zGiMq/nk= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf22.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.229 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp43.blacknight.com (Postfix) with ESMTPS id 4CC551E7B for ; Sat, 13 May 2023 11:27:08 +0100 (IST) Received: (qmail 24941 invoked from network); 13 May 2023 10:27:08 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.21.103]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 13 May 2023 10:27:08 -0000 Date: Sat, 13 May 2023 11:23:14 +0100 From: Mel Gorman To: Tetsuo Handa Cc: Andrew Morton , Vlastimil Babka , linux-mm Subject: Re: [PATCH] mm/page_alloc: don't wake up kswapd from rmqueue() unless __GFP_KSWAPD_RECLAIM is specified Message-ID: <20230513102314.md5ugj22xnv6mxob@techsingularity.net> References: <6d6fb601-6100-92b9-cea3-e7ebacc7693a@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <6d6fb601-6100-92b9-cea3-e7ebacc7693a@I-love.SAKURA.ne.jp> X-Stat-Signature: 5mtb59yddm4djsd6p9rfuzwth1nzg8bw X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 46215C000A X-Rspam-User: X-HE-Tag: 1683973629-231213 X-HE-Meta: U2FsdGVkX18YNW0MsCQTDiMpSW8NU7KzVY81+VWqQY8Vg8hCX9fScNxYVl+UlYebw+87t5+tSZMMOnqiXU6xsI9Yt78aHBl3fw3db5Evh/yk3nJHaumwsPIT6Y052wZAiXnJZ0yuZ3ewFeqhaxvgFP8kie5qqtzrTJlGQOVfKMphJDA+GIqLpaeP59JbprQ99KHEb/JK1OlzBPR+Z/KnIft8y9GbFPP6cyAADMMFsR+RRH2h9KBweKVTTBvGazs+Qg+56Nv9TyoGrEaBl/vd/UGfu8Sm7Zesutg0R/XUJ0ChiXZgBcggBCZegVDBzuCOBhbYRJFUgNMjzR8OJkilqtKYi09fM/kAXMkTFDx4W9sFkIONKrGfMW+fqPZfEvUC+mhLbMaC+xGojd0uYoLhpk5MUqhbzujurchqzUxqnBICvj6CH/oJiaBE3JHyE1bzypojrr4H7p+0lMnYETS6NCZpQWsEabzPAyId8MdoXzA/oxQzzF/9faclRQNTEbRbWX+S/af+1exgfWtAGRmmnMcF8/PhjD5JcMiHExVuQq/QmqHDl6HwHN7FQFW6EiU3A6600PVg7IomwNWxsmARs6DANVZUeS9cFe9GoNJJEyzclJo5UxTtO4QURgIF4d0giDbXcP1czWnEreU80OhOuwxVV1jUTYLYUq9tpvV8V2z5da8XnuPKdwawyL/kmoHbB+s9TOoKRgPVd1lrQPZUXctMNjLjYEzr9IG1MR2NfBdQii6YA8GMEKz1asxFShoL+Q08/iczS410r8jkiULIvRVMrXLyXbWvsKDs64oCKMWdD5STzBZGQb9vSVPn7U078IuidAg6Oqv4DpB9/3VbG6i64h5nXU6P8KTQRh182wNQOPuDu2yorSkDdD+6Z/2PRymXAR9mNf/JYusorxi7/DSxq+L4VuykVZgB0mh2z1KPJkdjOUWU8HBTdNtHZk15Vl5i1UOeNxaC+YMyS9V DuPX/FhN ePaAZTEKW/QwRfOhageN0ahGF1VHSufKMHLM2ofzfqUKxFJPIU3RoNe8lJWl/Cxbt+kNwwK8sJAZpcqQDdU6IChCWjw1Kj2WmBpOrAfP6t8u4LM1dDXQcgWotS//R4MM0bfX/7flWS2UOHiDvVNp3PQ/z5Ta8dHjg0jf/l0VhCHubGcL6lR+62IHv9WuFLM4+4tGvedsZ894FKB9yblrxmREjsw== 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 Thu, May 11, 2023 at 10:47:36PM +0900, Tetsuo Handa wrote: > Commit 73444bc4d8f9 ("mm, page_alloc: do not wake kswapd with zone lock > held") moved wakeup_kswapd() from steal_suitable_fallback() to rmqueue() > using ZONE_BOOSTED_WATERMARK flag. But since zone->flags is a shared > variable, a thread doing !__GFP_KSWAPD_RECLAIM allocation request might > observe this flag being set immediately after another thread doing > __GFP_KSWAPD_RECLAIM allocation request set this flag. > > Signed-off-by: Tetsuo Handa > Fixes: 73444bc4d8f9 ("mm, page_alloc: do not wake kswapd with zone lock held") The issue is real but it needs to be explained why this is a problem. Only allocation contexts that specify ALLOC_KSWAPD should wake kswapd similar to this if (alloc_flags & ALLOC_KSWAPD) wake_all_kswapds(order, gfp_mask, ac); The consequences are that kswapd could potentially be woken spuriously for callsites that clear __GFP_KSWAPD_RECLAIM explicitly or implicitly via combinations like GFP_TRANSHUGE_LIGHT. The other side is that kswapd does not get woken to reclaim pages up to the boosted watermark leading to a higher risk of fragmentation that may prevent future hugepage allocations. There is a slight risk this will increase reclaim because the zone flag is not being cleared in as many contexts but the risk is low. I also suggest as a micro-optimisation that ALLOC_KSWAPD is checked first because it should be cache hot and cheaper than the shared cache line for zone flags. -- Mel Gorman SUSE Labs