From patchwork Thu May 11 13:47:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 13237975 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 D2AC7C7EE22 for ; Thu, 11 May 2023 13:49:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F33B6B0080; Thu, 11 May 2023 09:49:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A38B6B0081; Thu, 11 May 2023 09:49:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56BFA6B0082; Thu, 11 May 2023 09:49:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 486546B0080 for ; Thu, 11 May 2023 09:49:16 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D32881202CD for ; Thu, 11 May 2023 13:49:15 +0000 (UTC) X-FDA: 80778105870.04.4B084AB Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by imf06.hostedemail.com (Postfix) with ESMTP id 914DF180161 for ; Thu, 11 May 2023 13:47:43 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=none; spf=none (imf06.hostedemail.com: domain of penguin-kernel@I-love.SAKURA.ne.jp has no SPF policy when checking 202.181.97.72) smtp.mailfrom=penguin-kernel@I-love.SAKURA.ne.jp ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683812864; 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:content-transfer-encoding:in-reply-to: references; bh=o8oh2+pcSsiogHvfwCodtCuxJxz7D1erY6aGAHyQEws=; b=zM4a0wQzX8tTHucDCKn4ChXoH2/kyKDeEUClT69IUkzilwQnjBHI1MaBvr1JDcPkQDWI5V ccRThSNC+V3LpYjpwsNvDviUoNjtGr0P+OAP1zgonzCgzFgHqSGdr7wPdxT/ZO5F0oMjUb 5/X6Dh85o6aVFJA5PLfzkKEJB/voEfI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683812864; a=rsa-sha256; cv=none; b=DfqYQXE7FvFAPgHTYEAJlJ0m/hFEDnJXM1dwMUf+IFdUPPm0rPmSIPhbR4UJ5nBAr2ZLJM P5+vSwuzitkmtzCEIgnBf6j3UzUQbsxzZWjw4CXavhYK2fXYJ7v+esF1WGsONqTX4vE2dN QxoUqAD8z3rXJpJa279gKarauLBL9AA= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=none; spf=none (imf06.hostedemail.com: domain of penguin-kernel@I-love.SAKURA.ne.jp has no SPF policy when checking 202.181.97.72) smtp.mailfrom=penguin-kernel@I-love.SAKURA.ne.jp Received: from fsav415.sakura.ne.jp (fsav415.sakura.ne.jp [133.242.250.114]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 34BDldIB062234; Thu, 11 May 2023 22:47:39 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav415.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav415.sakura.ne.jp); Thu, 11 May 2023 22:47:39 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav415.sakura.ne.jp) Received: from [192.168.1.6] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 34BDlcZW062231 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Thu, 11 May 2023 22:47:38 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: <6d6fb601-6100-92b9-cea3-e7ebacc7693a@I-love.SAKURA.ne.jp> Date: Thu, 11 May 2023 22:47:36 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Content-Language: en-US To: Andrew Morton , Vlastimil Babka , Mel Gorman Cc: linux-mm From: Tetsuo Handa Subject: [PATCH] mm/page_alloc: don't wake up kswapd from rmqueue() unless __GFP_KSWAPD_RECLAIM is specified X-Stat-Signature: gk9azgqrcjkb5abput8hki6mc9u9e6mo X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 914DF180161 X-Rspam-User: X-HE-Tag: 1683812863-979607 X-HE-Meta: U2FsdGVkX1/jPz8ooVR2rd1UyzZRymASewStRhEC1v7Ge5IIyjLlzvM1m5ZKtrUvfMeKF32cjNbWlsmuErKj1VRsFO93oP7pjxsZZySub9k73OVauhbMhVQcIEzVop61G8ccXplwXBe08MbAHZbMCWcvVPUW8hFq/Y1/WOtXn3ugsy8hwsfwHPQ666XBgTfA/VPlbEmGLRoQ60Dta6/DOyXvc365USkMEGhTZbrALFtZRSxHWhDEZj+QgUHeouEELILCBO3yLhygmpHRRdv7X//CJiuZHZrqbrnwn6r82/nk/JIjxQEEvN8YTdfnT7Io0JPrBSxSD7PdtQWXiUUOrDDrIxnK1+KsJQoszq1H9/se8UmQz1VCHPB6h2WgH+wf+fs0+972xwq1MN0QbUJOLc8tiz1N5EHCCh3/Y7YTxMzazC3gWYd/8bz/y0BL0MgOvYrbTwuJ1nnuQui4g8G9MGs+MOKXbINvvnKqLofvynd7DzmsZJA0BJ4ZKjwd9uUUK7gPfJuUyd2LYfv344qvfCArdlWZLvjT84pcBiUZD2rNhBxRy/2W/oBLLOxd+2rpflcu3DR0ge/snbfr+cd8aUQbj8bOElJ6JjkGlsKNnvIBlSkPx8bK0cwp0bvcbo9RrwWIdtpc/nbAf7XTfBh05cnAXbTBGsGzgoTo4Hcs2/Fi37NemrC5b7235dxN7ez4mXyjxezcyBHJjJpW/0O9ZjCvbSzwcJr/Nu2q4pVESINDR0mf24VgAICWZ5NRzMGiZ6UKnSj939B1DMJUjNqPKWSJ3v50Qiah6icURvHjNtsFIk3Pix9V28tfm24NjyaqdukzymRGOwgWMKybN3Ggx1yv6UEeL2lw2cbJcr/LSFwqPu5p6qFT3sLVI/tS0pcKaOVUOnG/5pZQX3PMgZVMvJpFC6g6n1k1qHC+HWL6TNindVp8bElah+66Q43sRMCpP37jSA4qAl/jcXRhYip uaF9w5os +Np3mOHLx1R/5bCfsLOTcnmlbPbLAto7VG72VLlUL7gHTtrsXG3+kzLF+IVJVTJP/bKRiRDMQZcQFDloe8CIxbHB0xk8DBH81+bpuclquphnMK33VA7gyc71LVnHyh/OFCoB8z5r1j4vpr3/22ZGkqNAIGZwwGqGs9ia6xT79rDyrQyWGj2zYBxTu7l3ovOGyh7LAI/J4RoY2sHYXKosGBdymbZLj6mlZi6qWOvko1U6rxAaeecAI8HqNxG047pe2SfiY 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: 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") --- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 47421bedc12b..4283b5916f36 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3052,7 +3052,8 @@ struct page *rmqueue(struct zone *preferred_zone, out: /* Separate test+clear to avoid unnecessary atomics */ - if (unlikely(test_bit(ZONE_BOOSTED_WATERMARK, &zone->flags))) { + if (unlikely(test_bit(ZONE_BOOSTED_WATERMARK, &zone->flags)) + && (alloc_flags & ALLOC_KSWAPD)) { clear_bit(ZONE_BOOSTED_WATERMARK, &zone->flags); wakeup_kswapd(zone, 0, 0, zone_idx(zone)); }