Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2366172rdb; Mon, 11 Sep 2023 22:17:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAdHlFaLaWCpbEnEJ8DQDKF71yxOZMY6iwfT4B4dlu+F5TngZ2rIDN/wWcXy09Z5zOKF2Q X-Received: by 2002:a17:902:e811:b0:1bc:3908:14d with SMTP id u17-20020a170902e81100b001bc3908014dmr1857216plg.2.1694495877463; Mon, 11 Sep 2023 22:17:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694495877; cv=none; d=google.com; s=arc-20160816; b=CGlsWxzktzjwQ20CRVAh6UHecPUTTEydHIfzZZYs2mrVuVzKAc7lORH9oxZalx2/sJ 48fc3BcBEtYJ8UWt0nzvG6q0Yi0kQRvsPl5li0I+suOXAzTk/L3uuZ/iFoTTw7uhA1zP Wy6P+fz4vjPuXEspjh4RKQn8FTxgEqIpvp+PR923d5jhv9MSselw5r0a4BtxkkXxarry ys9usxcu+C9Y2fguPrQTukOBJ0Xd8ZlHEQj3kC9L9oN8kQUYS09G6J+YcoMBS5Cn7dDH 7sRn/RNbQ1iVcG39WNby+XuXaiocydYZ78+/g/WDYefEis3ufl9G/9tc3GOdEf6A63xP Axmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/5wfKROfQzJ0THtXwPhZ2MaEveOMLddN1As4uGdsGq0=; fh=9YzsDNfMGFr3eaMUz+s/SjcXJc8ETWu4nLDmCpqODlw=; b=k/ZJNrNmKGPsfSZYoeeXwIdZVyX0lVXH0pTmP71bNQbufez4BcdvSlGlHRb0LiAWnt lk3df9VPEQsagMQU5kGgwwNd9kb2+twZy/DnaomOshHIeeAQTwPVw8izevi8FDySbywi rKU4hLUyI0HM1WlfLTGuqsQ9cRB++j424ExnUzHT5MsOKS+nA2LRxXcPymBKO2rZ+bkR n8rO/M+/kasJzchNvSH2Eve7c7VCOdCuNz7jXJSaiv+KOR5lTz4chGKOKG4XSBa1/ahe o7+VwW+ZLCo0gydPvrsf9vJmR31LAUYwQJ5YW9oZN75wnzxUABfSwvhloWo0wQvlbxOd iEgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q9uNrRTY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e62-20020a636941000000b00563f627f2easi7259400pgc.122.2023.09.11.22.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 22:17:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q9uNrRTY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D422B804596D; Mon, 11 Sep 2023 21:05:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236181AbjILCVC (ORCPT + 99 others); Mon, 11 Sep 2023 22:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235897AbjILCUC (ORCPT ); Mon, 11 Sep 2023 22:20:02 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E15188A49; Mon, 11 Sep 2023 18:43:10 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6DFFC116A1; Tue, 12 Sep 2023 01:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694482990; bh=MZfgo6MURz3BgruLFMBLXwS/8zrB+gqE+MzIheFwuyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q9uNrRTYqaajPGhKYGdTDqSCvE+I3yEoL60HbVUdoQoEJ7vzKYfmNUP53+Mypx2q1 8OIwfqagUNN5TnPbd5zsQPJLoSvgv5bdmvWmyzpcegmaus2km+4OdqGibOxNLDgy5t k4RdZ78uKAfS++llOiKcM3aTM9rEajLrrCs7gXmwPg+j71glXOaXNbtJWPF87eym0b apqMKxjA67c24htXl1O76cWLhuaGPlRSk5sC7FsSVFbEupM5cwJOtiNnXoQqRqgB13 NO903WTV7hKDNuhOb1PEAzexCl5j0DEkNDlXmS5f3K9yBmLmp3PAEtWy9bIj+Jm4cB 9qAACSsgygBxQ== From: SeongJae Park To: Steven Rostedt Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] mm/damon/core: add a tracepoint for damos apply target regions Date: Tue, 12 Sep 2023 01:43:08 +0000 Message-Id: <20230912014308.38298-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230911165144.5002a0ac@gandalf.local.home> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 11 Sep 2023 21:05:54 -0700 (PDT) On Mon, 11 Sep 2023 16:51:44 -0400 Steven Rostedt wrote: > On Mon, 11 Sep 2023 20:36:42 +0000 > SeongJae Park wrote: > > > > Then tracing is fully enabled here, and now we enter: > > > > > > if (trace_damos_before_apply_enabled()) { > > > trace_damos_before_apply(cidx, sidx, tidx, r, > > > damon_nr_regions(t)); > > > } > > > > > > Now the trace event is hit with sidx and tidx zero when they should not be. > > > This could confuse you when looking at the report. > > > > Thank you so much for enlightening me with this kind explanation, Steve! And > > this all make sense. I will follow your suggestion in the next spin. > > > > > > > > What I suggested was to initialize sidx to zero, > > > > Nit. Initialize to not zero but -1, right? > > Yeah, but I was also thinking of the reset of it too :-p > > sidx = -1; > > if (trace_damos_before_apply_enabled()) { > sidx = 0; Thank you for clarifying, Steve :) Nevertheless, since the variable is unsigned int, I would need to use UINT_MAX instead. To make the code easier to understand, I'd prefer to add a third parameter, as you suggested as another option at the original reply, like below: --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -997,6 +997,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, unsigned int sidx = 0; struct damon_target *titer; /* targets iterator */ unsigned int tidx = 0; + bool do_trace = false; /* get indices for trace_damos_before_apply() */ if (trace_damos_before_apply_enabled()) { @@ -1010,6 +1011,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, break; tidx++; } + do_trace = true; } if (c->ops.apply_scheme) { @@ -1036,7 +1038,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, err = c->callback.before_damos_apply(c, t, r, s); if (!err) { trace_damos_before_apply(cidx, sidx, tidx, r, - damon_nr_regions(t)); + damon_nr_regions(t), do_trace); sz_applied = c->ops.apply_scheme(c, t, r, s); } ktime_get_coarse_ts64(&end); Thanks, SJ > > -- Steve > > > > > > > set it in the first trace_*_enabled() check, and ignore calling the > > > tracepoint if it's not >= 0. > > >