[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aFq12y2R/KV4UKyT@e133380.arm.com>
Date: Tue, 24 Jun 2025 15:27:56 +0100
From: Dave Martin <Dave.Martin@....com>
To: Su Hui <suhui@...china.com>
Cc: Dan Carpenter <dan.carpenter@...aro.org>, tony.luck@...el.com,
reinette.chatre@...el.com, james.morse@....com,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] fs/resctrl: using guard to simplify lock/unlock code
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@...china.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
>
>
Powered by blists - more mailing lists