From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx.treblig.org (mx.treblig.org [46.235.229.95]) (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 A11422FF173 for ; Sun, 28 Dec 2025 12:46:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.229.95 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766925972; cv=none; b=etla+OAem8iuj5FtseqjkHw99cmJS9E6hMj975bjVufqZn00iZYlNh8uk3q51cpGSePZJt8+MunrlebONYkrI3YXXI8A/3g+P1wRysD47aS02jN/KqnpKGqclDlZXApiUwN7wLR8T4BDtdc+t8DP/GU61qCiOsbVdk/I7aC561E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766925972; c=relaxed/simple; bh=8qFmjxSaLQdbpcTkQRcNVXoDYSXnZ0kzo73GFGO7ILo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=i/0DR+JnFngZVq/SubKyhaXymV/Y5mpw/0M4DBPurZDmYi11gtKw+QcG99TMiX/jtNgoDpx1gFSqV6KUVglFFxpipOdSkC7NUSx7sjBL2qQonSPfM51wt4SjmBxaQKpwxnEbP669ytKSuXZ9DEiYq2RCaPEtcxKEoObeisHZUl0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=treblig.org; spf=pass smtp.mailfrom=treblig.org; dkim=pass (2048-bit key) header.d=treblig.org header.i=@treblig.org header.b=PQgCm8Lp; arc=none smtp.client-ip=46.235.229.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=treblig.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=treblig.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=treblig.org header.i=@treblig.org header.b="PQgCm8Lp" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=treblig.org ; s=bytemarkmx; h=Content-Type:MIME-Version:Message-ID:Subject:From:Date:From :Subject; bh=MXXKkPhQ6INWD5WOaMwf9OHgcU0hhmQRgzClVoYajJg=; b=PQgCm8LpYyZpk9PO M6fDAJcQhyBQok78sGN3TuZzL/oA2K6hADV/KkFWj22NqedyO/TGkWRdYRAwgce1aAyFT+LRxsyL5 pVobrbDgOQVhqmOg1ixwOgeAldX+XTf9gSj96IqJhn1gb58KdmvaBuEOez24I6mwyzakpmeqL7Ztz fT3knY8YSK81tXfQA280eCf9nbKIiZxuXJpeoUP2AUYA+TTuf53TwilVbmHXUuMA5nxkD1LFuvWX+ fu/9hkebd1tgHzreKSM5Uw90NEv/i8+Gt0U1sz6msqPBym5yQbei6hqzhAIe2OxyWjEyvjIuzH+4o TMp5QwiquMhyvBw5Ag==; Received: from dg by mx.treblig.org with local (Exim 4.98.2) (envelope-from ) id 1vZq9p-0000000BUDr-0Xhb; Sun, 28 Dec 2025 12:46:01 +0000 Date: Sun, 28 Dec 2025 12:46:01 +0000 From: "Dr. David Alan Gilbert" To: "Paul E. McKenney" Cc: Julia Lawall , Theodore Tso , Steven Rostedt , Sasha Levin , Gabriele Paoloni , Kate Stewart , Chuck Wolber , Dmitry Vyukov , Mark Rutland , Thomas Gleixner , Lorenzo Stoakes , Shuah Khan , Chris Mason , linux-kernel@vger.kernel.org Subject: Re: Follow-up on Linux-kernel code accessibility Message-ID: References: <20251225150331.GB15088@macsyma.lan> <20251226114830.6bc7a3eb@gandalf.local.home> <20251226192217.GB67711@macsyma.local> <6915da9a-6cd7-c2a9-776d-963949a413c@inria.fr> <8005c35a-d8dc-4908-93e5-46bd206f0139@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8005c35a-d8dc-4908-93e5-46bd206f0139@paulmck-laptop> X-Chocolate: 70 percent or better cocoa solids preferably X-Operating-System: Linux/6.12.48+deb13-amd64 (x86_64) X-Uptime: 12:35:41 up 62 days, 12:11, 2 users, load average: 0.00, 0.00, 0.00 User-Agent: Mutt/2.2.13 (2024-03-09) * Paul E. McKenney (paulmck@kernel.org) wrote: > > > > > > > > j = (j + 2) / 3; > > > > > > "Divide by three rounding up." > > > > That's not *that* obvious, but ok, but then why 3? > > > > Then later there is: > > WRITE_ONCE(rcu_state.jiffies_kick_kthreads, > > jiffies + (j ? 3 * j : 2)); > > > > Which I assume is related - but then why the 2? > > Would the two of you (Julia and Dave) like to join in with Steve and > myself walking through this function and its caller? Not sure what you mean join in; not really set up for a call etc at the moment, but happy to continue a mail chain. But, if we're talking about the understandability of these few lines, it looks like this could be something like: // We have 3 ..... for the case when ... const unsigned long something = 3; .... j = DIV_ROUND_UP(j, something); which would seem to make it more readable with very little effort. (Hmm, since j is unsigned long why do we have a test of: if (j <= 0) j = 1 ) Dave > > Curiosly my local tame Qwen3 LLM explained the rounding up: > > > > > I see some code doing 'j = (j + 2) / 3' - what's it trying to do? > > The expression `j = (j + 2) / 3` is a clever way to **round up an > > integer division by 3** — that is, it computes the ceiling of `j / 3` > > for non-negative integers. > > Good to see! > > Thanx, Paul > > > Dave > > > > > > > > Thanx, Paul > > > > > > > > > julia > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanx, Paul > > > > > > > > > > > > > > [1] https://docs.google.com/document/d/1GCdQC8SDbb54W1shjEXqGZ0Rq8a6kIeYutdSIajfpLA/edit?pli=1&tab=t.0#heading=h.ytgz5i5df43s > > > > > > > > > > > > > > [2] https://www.kernel.org/pub/linux/kernel/people/paulmck/perfbook/perfbook.html > > > > > > > > > > > > > > > > > -- > > -----Open up your eyes, open up your mind, open up your code ------- > > / Dr. David Alan Gilbert | Running GNU/Linux | Happy \ > > \ dave @ treblig.org | | In Hex / > > \ _________________________|_____ http://www.treblig.org |_______/ -- -----Open up your eyes, open up your mind, open up your code ------- / Dr. David Alan Gilbert | Running GNU/Linux | Happy \ \ dave @ treblig.org | | In Hex / \ _________________________|_____ http://www.treblig.org |_______/