mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Martin <Dave.Martin@arm.com>
To: Su Hui <suhui@nfschina.com>
Cc: Dan Carpenter <dan.carpenter@linaro.org>,
	tony.luck@intel.com, reinette.chatre@intel.com,
	james.morse@arm.com, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] fs/resctrl: using guard to simplify lock/unlock code
Date: Tue, 24 Jun 2025 15:27:56 +0100	[thread overview]
Message-ID: <aFq12y2R/KV4UKyT@e133380.arm.com> (raw)
In-Reply-To: <cf505dc6-c123-44fd-9ee6-5aac4764f905@nfschina.com>

Hi,

On Tue, Jun 24, 2025 at 10:46:24AM +0800, Su Hui wrote:
> On 2025/6/23 23:14, Dave Martin wrote:
> > Hi,
> > 
> > On Mon, Jun 23, 2025 at 07:25:41PM +0800, Su Hui wrote:
> > > Using guard() to replace *unlock* label. guard() is better than goto
> > > unlock patterns and is more concise. No functional changes.
> > > 
> > > Signed-off-by: Su Hui <suhui@nfschina.com>
> > How were these cases chosen?
> I chosen the code  that match with "*unlock*:" label.

Right -- that was what I guessed, but thanks for confirming.

> > 
> > I notice that this patch only handles some straightforward mutex_unlock()
> > cases.  There are other opportunities in some places -- particularly
> > alloc/free patterns.
> Yes, as Dan mentioned[1], there are too many these patterns and I'm not sure
> how
> much value we can get to do this things. This patch is a try that using
> guard() to
> remove some  lock/unlock pattern and simplify the lock code.

Agreed.  guard() is not a bad thing, but it's probably easier to use it
cleanly when writing new code.  Backporting it into existing code might
be worthwhile it it clearly makes the code simpler or fixes bugs, but
these cases in resctrl feel like they don't bring a lot of benefit.

> > Overall, I'm not totally convinced that backporting the guard()
> > infrastructure into code that wasn't originally written to use it is
> > always worthwhile.
> > 
> > If the code is simple, there is not much benefit.  Otherwise, there is
> > a significant chance of unintentionally changing the behaviour of the
> > code (though the exercise may be useful if it identifies actual bugs).
> > 
> > Either way, such changes will get in the way of people who are rebasing
> > on top of this code.
> Got it, it's ok to omit this patch. It seems this patch has not enough
> value.
> > FWIW, this patch looks OK though, and the diffstat looks reasonable.
> > Since this code was recently moved into fs/, diff context noise may be
> > less of a concern.
> Maybe only for some complex lock/unlock code, guard() can bring some value.
> Thanks for your advice!
> 
> [1] https://lore.kernel.org/all/d07fe2d9-3548-43fc-b430-2947eee3145b@suswa.mountain/
> 
> Regards,
> Su Hui
> 
Fair enough.  Considering how guard() _might_ be used can be a useful
exercise, even if the changes are not adopted everywhere.

Cheers
---Dave
> 
> 

      reply	other threads:[~2025-06-24 14:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23 11:25 Su Hui
2025-06-23 15:11 ` Dan Carpenter
2025-06-23 15:14 ` Dave Martin
2025-06-24  2:46   ` Su Hui
2025-06-24 14:27     ` Dave Martin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aFq12y2R/KV4UKyT@e133380.arm.com \
    --to=dave.martin@arm.com \
    --cc=dan.carpenter@linaro.org \
    --cc=james.morse@arm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reinette.chatre@intel.com \
    --cc=suhui@nfschina.com \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®