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 C9D0FC5474A for ; Wed, 28 Aug 2024 02:42:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 318626B0088; Tue, 27 Aug 2024 22:42:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C87D6B008A; Tue, 27 Aug 2024 22:42:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 190BB6B008C; Tue, 27 Aug 2024 22:42:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id F05046B0088 for ; Tue, 27 Aug 2024 22:42:16 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7E7C7AAE51 for ; Wed, 28 Aug 2024 02:42:16 +0000 (UTC) X-FDA: 82500105072.07.A94D2AA Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) by imf27.hostedemail.com (Postfix) with ESMTP id 860BA40008 for ; Wed, 28 Aug 2024 02:42:14 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=CHXijeje; spf=pass (imf27.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.189 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724812890; a=rsa-sha256; cv=none; b=Xvc8klWdCnpeIXFD97BrPEJLDjxoNmlGW1BznpRK35J6nwgbRkhxgATtrEvehekm2tewXj 1QzyqX7HcLV04A6TTwowM+Hs2UbwybULUMvX63AvvzqkIIZDobZr9BEw20ceHvGFraEf77 C63rh+zdtAa+jvFk65lMf3uHGrHnw/M= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=CHXijeje; spf=pass (imf27.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.189 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724812890; 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:dkim-signature; bh=tmuII7hQ9ekox8gX+3Eyt9Apec88eBQCZ5MKKI3oR6E=; b=u9L9smxaxAWC2m5ja3KgLM4zuKogcJfkVBkOl00WuKOcMagQmv7k+BgxVrPzvxiFwA2kCA p4akOZgMdSQtRKtIt6oyZcKfiX+LfOiPSW5OHUEuZosotZcM0ACKZ5Nd9/G4ECUdPKXeBm uA1rZefWB/84zJFIfoUgnA1nmnbrDHc= Date: Tue, 27 Aug 2024 22:42:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1724812933; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tmuII7hQ9ekox8gX+3Eyt9Apec88eBQCZ5MKKI3oR6E=; b=CHXijejetQ0RMCgVRW4jX9Bdqm9/GTaDSN6owYiVcIDcXuOLqHooUvVvDN6xDSOfTLwGQS +pgL1JCo0LYs4PL+h3dTTVay5NST3YtY+sMSuWvJSkkcn6o69ItwZrtnDzaSgfU9sFFMUR kDf5Kt7k4LxzQi20sYE4ap6OhEbsgMQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Dave Chinner Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Qi Zheng , Roman Gushchin Subject: Re: [PATCH 03/10] mm: shrinker: Add new stats for .to_text() Message-ID: <4hbbj5humpek7tou2q36t7x4kekodp3lsacrpyhvnrfz5kwnbb@vxk54hbuxyw2> References: <20240824191020.3170516-1-kent.overstreet@linux.dev> <20240824191020.3170516-4-kent.overstreet@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Stat-Signature: hgem6deihiay65bd31uug9cfjfkjsno5 X-Rspamd-Queue-Id: 860BA40008 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724812934-746269 X-HE-Meta: U2FsdGVkX1/4HDs2Qh+O3hsl2d0MQy+1h9PjNPkwYerN3qsR4BX7I9FiA+iiW84xR4KsSBMA+8lrfpaTWdM7lmBWB7GRab0lNBvy2RbBEThJY7WvwEsVCetW8zqJ8/e3L83JLyJyDTztvbDtacpOj5PDyiWE5wMAKd9iHsWh+O5Pj5g8TWuZfbjOXeTiDTHiMe58D2BCLy5IuAJxm2w89Ar0v/Cx1R3aYrXhFQNU9IN2FXQwmhwFEg/g8CJgkgHh/APeimen8AHtVOdjGHNXUv7h5WXdIzTzADleJwcjPX//UdVu9SjhwKkJwwQuLgaYz2wTNQwQD1wAMIdoEc/FLzkyrN36JU/+pSMSZWw1E6GP8hsrjvbhEBTrEmqjmSQ5iVOCFu6vFKZcZZN/dQMyss9gGM+FFyfAbs2irjh7oPgbkAPFHhNNugs1n/9U1PNAAvPC8SqySv7dZ0JMp3ZV+zYr/XQ6EtQezo7ADg6HMYj5SyBAy6l84KWzSZrD17CUjBXIKXs+1XxR0MWZHuZ/6mydA6xhqnFupDv8KlZJ34NEzUu1vCMgxVPArqaFIfCyFf7W+v7DtIbogdN44lweVG1dsAFHlWiyov4yD4gvamd98jQAIYi6FsO9bs3/D8C/q/UXHalgf7MNpS/Fj3x1QtkWGPF5SwVfeaxUCB2BSOwBxdILrLU+XcfMOJhUP4iEmLglrZmjcjLLr2ET5+FKigLNnqZL2vYEYFFTAdzZnWUYXTya+vkwcPl7+Vl+RTP4oUxxFztNRvTN+nP9zNB/GK8d7336IYyhhs4ysdZjo+OP7XG8SjUS83sDKSV4d2DFm0I934jYojIYKEbDeoR71zqgXcrjytUMCS2JZx30VnQBY1KKy6tcJYpGVUD1uq0O5c15qpgmIXfWnJMttdCzNH02TaDdnVQK35enm2gQxzdPmLcDb5uLkpP1hF9kmViZVIkXoZlau8C9HhYtcDt GUFTYpa8 fvyLxYO6ybAQmstNVUsLDH3Onp1679KyWqhAE3u/f6FkAaxbFNTRNR4vZ/fZUEfEiLXlf3ByGFhoC7SrSbz7Wa8n8dIxqvEJcczbOjsLjISCYsTcmwkNqism77OgsYXrSokhy7eGIKeRbs2mlgART9TsOLZb0Zoi7bIIyYafvjY89gl5LyjNfru0sulCoLKdSmcyJ 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 Wed, Aug 28, 2024 at 12:36:08PM GMT, Dave Chinner wrote: > Doing this inside the tight loop (adding 3 atomics and two calls to > ktime_get_ns()) is total overkill. Such fine grained accounting > doesn't given any extra insight into behaviour compared to > accounting the entire loop once. > > e.g. the actual time the shrinker takes to run is the time the whole > loop takes to run, not only the individual shrinker->scan_objects > call. > > The shrinker code already calculates the total objects scanned and > the total objects freed by the entire loop, so there is no reason to > be calculating this again using much more expensive atomic > operations. > > And these are diagnostic stats - the do not need to be perfectly > correct and so atomics are unnecessary overhead the vast majority of > the time. This code will have much lower impact on runtime overhead > written like this: > > start_time = ktime_get_ns(); > > while (total_scan >= batch_size || > total_scan >= freeable) { > ..... > } > > shrinker->objects_requested_to_free += scanned; > shrinker->objects_freed += freed; > > end_time = ktime_get_ns(); > shrinker->ns_run += end_time - start_time; > shrinker->last_scanned = end_time; > if (freed) > shrinker->last_freed = end_time; > > And still give pretty much the exact same debug information without > any additional runtime overhead.... *nod* This is all going to be noise compared to the expense of ->scan() itself, but there's no reason not to, I'll make the change...