From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EAE2364951; Fri, 20 Mar 2026 15:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774021882; cv=none; b=i3qM4u10wWXbvfDzj87Bt7nKW6DsOzXx2kvbHGujWFBOomG7FVxMuRYtSDpUPWHeF30LA0EnlqdAhl5lmYlrgAtPGCfX1E6hyosJ+O3lwX22or6czEQ0Qo3XB2EXcMmyPzw1w74nNGnE56W02bVNYM4Hcz7PgaZ+F5AQDs+DeoQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774021882; c=relaxed/simple; bh=oLa2yNfLRCVKbcj1mqAupr8pkOcbafxnJnVVjt/KHDU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jTvbQdeydS/oraLVGoxA53/kdsuOLKh2S/7MUTuhPgniKCF9a4AWGr1+hjkYnMMDL9bCDWPaA6RdGJAWKgwTF3Eak+CUHJZO2601YOhy2pBkJjZi1sdtk0SI/TrkAwG7cdvT7ayctgVaBHyISRuky+RK+3AMPPDGXLRpEUFWu6k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iPUHva13; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iPUHva13" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24479C4CEF7; Fri, 20 Mar 2026 15:51:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774021882; bh=oLa2yNfLRCVKbcj1mqAupr8pkOcbafxnJnVVjt/KHDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iPUHva13aLssUNKZdyL3hik6iWY1cm/v5s7YTF0Ichg3gjqm6xmraqBL73k8q3jHA wjt4ztB3Czdbf78qu9WzBHKlEI/OlO7aQBjzr4qgB2Pnw5l3XbQS9jEmQcK995Gbpt 1SC5r0zbWpAU7o4d2P8wuEUcyju9bdu5f8aodzzuSNkCZ984iUsQeyFiLg3WRKUKoN jFVMj+Io6AUEBaNwZhILTR+OSAfcg46osW+4SCJg07ye6hcPzWGFO98kBVKnJkY8kh ylwveh+bG+FfZT3D4UFdMYNdYsLVuoM8EHMPnB+vJ2lt9Q1bEQV6y4qOeO3mtUJi9m 9e+qBdnRiyzdA== From: SeongJae Park To: Josh Law Cc: SeongJae Park , akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 2/4] mm/damon/sysfs: check contexts->nr before clear_schemes_tried_regions Date: Fri, 20 Mar 2026 08:51:14 -0700 Message-ID: <20260320155115.101025-1-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Fri, 20 Mar 2026 15:14:54 +0000 Josh Law wrote: > > > On 20 March 2026 14:47:40 GMT, SeongJae Park wrote: > >On Fri, 20 Mar 2026 07:06:48 +0000 Josh Law wrote: > > > >> > >> > >> On 20 March 2026 02:13:17 GMT, SeongJae Park wrote: > >> >On Thu, 19 Mar 2026 15:57:40 +0000 Josh Law wrote: [...] > >> >Not necessarily blocker of this patch, but seems all the issues are in a same > >> >category. The third patch of this series is also fixing one of the category > >> >bugs. How about fixing all at once by checking kdamond->contexts->nr at the > >> >beginning of damon_sysfs_handle_cmd(), like below? > >> > > >> >--- a/mm/damon/sysfs.c > >> >+++ b/mm/damon/sysfs.c > >> >@@ -2404,6 +2404,9 @@ static int damon_sysfs_update_schemes_tried_regions( > >> > static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd, > >> > struct damon_sysfs_kdamond *kdamond) > >> > { > >> >+ if (cmd != DAMON_SYSFS_CMD_OFF && kdamond->contexts->nr != 1) > >> >+ return -EINVAL; > >> >+ > >> > switch (cmd) { > >> > case DAMON_SYSFS_CMD_ON: > >> > return damon_sysfs_turn_damon_on(kdamond); > >> > > >> >If we pick this, Fixes: would be deserve to the oldest buggy commit that > >> >introduced the first bug of this category. It is indeed quite old. > >> > > >> >Fixes: 0ac32b8affb5 ("mm/damon/sysfs: support DAMOS stats") > >> >Cc: # 5.18.x > >> > > >> > > >> >Thanks, > >> >SJ > >> > >> > >> > >> Hello, did you give Reviewed by you? Or not.. > > > >Are you meaning Reviewed-by: tag? If so, no, not yet. I want to get your > >answer to above question first. Could you please answer? > > > > > >Thanks, > >SJ > > > >[...] > > > Well, two is in the same catagory. But seperate fixes may be best. Because patch 3 dont call that function, so it may be screwy, i mean, if you want me to. Ill guard it. But its a bit on the hacky side I agree there could be more cleaner way. But these fixes need to go to stable, so I'd prefer a change that also easier to backport. So, yes, I want to. Thank you for kindly accepting my suggestion. Could you please re-post this series for the first and the fourth patches as they are, after adding my Reviewed-by:, Fixes: and Cc: stable tags, and a patch checking kdamond->contexts->nr at the beginning of damon_sysfs_handle_cmd() as I suggested? Thanks, SJ [...]