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 F07E9C3601E for ; Thu, 10 Apr 2025 08:51:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D1326B0301; Thu, 10 Apr 2025 04:51:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A7A26B0302; Thu, 10 Apr 2025 04:51:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 148E16B0303; Thu, 10 Apr 2025 04:51:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E84476B0301 for ; Thu, 10 Apr 2025 04:51:51 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C55DFC0709 for ; Thu, 10 Apr 2025 08:51:53 +0000 (UTC) X-FDA: 83317516506.24.E03C236 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf13.hostedemail.com (Postfix) with ESMTP id 27A192000B for ; Thu, 10 Apr 2025 08:51:50 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=tCyJbGPw; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Nc0k7Y9W; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=tCyJbGPw; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Nc0k7Y9W; spf=pass (imf13.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744275111; 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:in-reply-to:references:references:dkim-signature; bh=+EAeNUcXZ6Tir+sJZfVXkhzz4zdL/LImPcTbHi0NHl8=; b=RcaVlj1WxdfVfDk+pNMARzbFNIoLUmUT54pO9iJ91ipo0jlkxavWer58TKcNL9jxpQ7Fi0 bj4TtGZDtj1nhvRX++x8+TSShOeCFD5efa7o6L9OJL+glD1gAe5ztTqfYH+Hm12zwJVhdT Gzl8FjT86CBilYl0286Z48iJ5P5xd2Y= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=tCyJbGPw; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Nc0k7Y9W; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=tCyJbGPw; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Nc0k7Y9W; spf=pass (imf13.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744275111; a=rsa-sha256; cv=none; b=HWTYxvAPi67ad6tM36IlDpt7e4gG4MVX7AtDMwDcCh4IajtrefaB3S7JXY0MkRdqzXjOHC Vwb0WajKXuDQFcG0WMVlVSFn6o6zYXBHtheKdFBuMlmiLKAlvR00D/uhF4Tx3QxUK5zQSL DogYZx881y0UEUovEdT+4d+6EujC/oY= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8D37C1F38C; Thu, 10 Apr 2025 08:51:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1744275109; h=from:from:reply-to: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:in-reply-to:references:references; bh=+EAeNUcXZ6Tir+sJZfVXkhzz4zdL/LImPcTbHi0NHl8=; b=tCyJbGPw38uAn4ArAK6UuiXmTsHCMM4E/lWbgB8JShi0PwGMztMperTnPpQteuEH7NZyWA XSbCfNSCPdej6Beai+0fH1YW/N9yHUqIDV8i1hlXqSzWv+qL8T6s7ftW+nv4xUgwenxC4o AbS4gbU2bJW0xYnS70nHo+fyzVaeumk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1744275109; h=from:from:reply-to: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:in-reply-to:references:references; bh=+EAeNUcXZ6Tir+sJZfVXkhzz4zdL/LImPcTbHi0NHl8=; b=Nc0k7Y9W+DeVdyouGFMrw0LVSN+2Qse8c0px9dCFFssyR2/TXZ4Bf/k2DMFq/t0N7rBEWP TPEHN3FLZmcxznDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1744275109; h=from:from:reply-to: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:in-reply-to:references:references; bh=+EAeNUcXZ6Tir+sJZfVXkhzz4zdL/LImPcTbHi0NHl8=; b=tCyJbGPw38uAn4ArAK6UuiXmTsHCMM4E/lWbgB8JShi0PwGMztMperTnPpQteuEH7NZyWA XSbCfNSCPdej6Beai+0fH1YW/N9yHUqIDV8i1hlXqSzWv+qL8T6s7ftW+nv4xUgwenxC4o AbS4gbU2bJW0xYnS70nHo+fyzVaeumk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1744275109; h=from:from:reply-to: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:in-reply-to:references:references; bh=+EAeNUcXZ6Tir+sJZfVXkhzz4zdL/LImPcTbHi0NHl8=; b=Nc0k7Y9W+DeVdyouGFMrw0LVSN+2Qse8c0px9dCFFssyR2/TXZ4Bf/k2DMFq/t0N7rBEWP TPEHN3FLZmcxznDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7B50813886; Thu, 10 Apr 2025 08:51:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id hRnJHaWG92eNDwAAD6G6ig (envelope-from ); Thu, 10 Apr 2025 08:51:49 +0000 Message-ID: <7e638027-7c50-4af8-ab6b-fa0a438098a2@suse.cz> Date: Thu, 10 Apr 2025 10:51:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] mm: page_alloc: tighten up find_suitable_fallback() Content-Language: en-US To: Johannes Weiner , Andrew Morton Cc: Brendan Jackman , Mel Gorman , Carlos Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20250407180154.63348-1-hannes@cmpxchg.org> <20250407180154.63348-2-hannes@cmpxchg.org> From: Vlastimil Babka In-Reply-To: <20250407180154.63348-2-hannes@cmpxchg.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 27A192000B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: ignqt37ygmq5e7wi6trwz84nj7zfzds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5bEBXdeWngumPf11G/+pARzjgpBXscP7F53kprKKd1XGVirKD/KzK61QzeHn9MfYMjTrogZRz6nmjUIJeF21189BwrkkG6IuKlIXenWRDrjRoUKJLPMqqM6Bg6urV3Rj1dUb6FkhCTsqzFmOWeePlp43I3CeTIsYgPAt4rvBoY0jUfM0l0AYdry6vH9/oQWdimn9d1ts69deJ5z83JwUn0f0vRsXQaCWnewUpzp8NFC7SynuePSiJbZVskMp3bes/tDONzM7foDEDYXSgO92fxdEKIYjR7sixvkAEAh1YfC1+f51h6KTymXNLwt6AnHLngQ5NdzsJ/9YOWUbYl267/9n9gXMU= 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: List-Subscribe: List-Unsubscribe: On 4/7/25 20:01, Johannes Weiner wrote: > find_suitable_fallback() is not as efficient as it could be, and > somewhat difficult to follow. > > 1. should_try_claim_block() is a loop invariant. There is no point in > checking fallback areas if the caller is interested in claimable > blocks but the order and the migratetype don't allow for that. > > 2. __rmqueue_steal() doesn't care about claimability, so it shouldn't > have to run those tests. > > Different callers want different things from this helper: > > 1. __compact_finished() scans orders up until it finds a claimable block > 2. __rmqueue_claim() scans orders down as long as blocks are claimable > 3. __rmqueue_steal() doesn't care about claimability at all > > Move should_try_claim_block() out of the loop. Only test it for the > two callers who care in the first place. Distinguish "no blocks" from > "order + mt are not claimable" in the return value; __rmqueue_claim() > can stop once order becomes unclaimable, __compact_finished() can keep > advancing until order becomes claimable. > > Before: > > Performance counter stats for './run case-lru-file-mmap-read' (5 runs): > > 85,294.85 msec task-clock # 5.644 CPUs utilized ( +- 0.32% ) > 15,968 context-switches # 187.209 /sec ( +- 3.81% ) > 153 cpu-migrations # 1.794 /sec ( +- 3.29% ) > 801,808 page-faults # 9.400 K/sec ( +- 0.10% ) > 733,358,331,786 instructions # 1.87 insn per cycle ( +- 0.20% ) (64.94%) > 392,622,904,199 cycles # 4.603 GHz ( +- 0.31% ) (64.84%) > 148,563,488,531 branches # 1.742 G/sec ( +- 0.18% ) (63.86%) > 152,143,228 branch-misses # 0.10% of all branches ( +- 1.19% ) (62.82%) > > 15.1128 +- 0.0637 seconds time elapsed ( +- 0.42% ) > > After: > > Performance counter stats for './run case-lru-file-mmap-read' (5 runs): > > 84,380.21 msec task-clock # 5.664 CPUs utilized ( +- 0.21% ) > 16,656 context-switches # 197.392 /sec ( +- 3.27% ) > 151 cpu-migrations # 1.790 /sec ( +- 3.28% ) > 801,703 page-faults # 9.501 K/sec ( +- 0.09% ) > 731,914,183,060 instructions # 1.88 insn per cycle ( +- 0.38% ) (64.90%) > 388,673,535,116 cycles # 4.606 GHz ( +- 0.24% ) (65.06%) > 148,251,482,143 branches # 1.757 G/sec ( +- 0.37% ) (63.92%) > 149,766,550 branch-misses # 0.10% of all branches ( +- 1.22% ) (62.88%) > > 14.8968 +- 0.0486 seconds time elapsed ( +- 0.33% ) > > Signed-off-by: Johannes Weiner Yay, you found a way to get rid of the ugly "bool claim_only, bool *claim_block" parameter combo. Great! Reviewed-by: Vlastimil Babka