lkml.org 
[lkml]   [2023]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 4/7] sempahore: add a helper for a concurrency limiter
    On Wed, Mar 29, 2023 at 09:21:12AM +0200, Peter Zijlstra wrote:
    > On Tue, Mar 28, 2023 at 10:31:46PM -0700, Luis Chamberlain wrote:
    > > While I looked at re-using the old kernel/kmod.c (now kernel/module/kmod.c)
    > > concurrency delimiter methodology for another place in the kernel Linus
    > > noted that this could be simply replaced with a sempahore [0].
    > >
    > > So add that so we we don't re-invent the wheel and make it obvious to use.
    > >
    > > [0] https://lore.kernel.org/all/CAHk-=whkj6=wyi201JXkw9iT_eTUTsSx+Yb9d4OgmZFjDJA18g@mail.gmail.com/
    > >
    > > Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
    > > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
    > > ---
    > > include/linux/semaphore.h | 3 +++
    > > 1 file changed, 3 insertions(+)
    > >
    > > diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
    > > index 6694d0019a68..2ecdffdb9814 100644
    > > --- a/include/linux/semaphore.h
    > > +++ b/include/linux/semaphore.h
    > > @@ -28,6 +28,9 @@ struct semaphore {
    > > #define DEFINE_SEMAPHORE(name) \
    > > struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
    > >
    > > +#define CONCURRENCY_LIMITER(name, n) \
    > > + struct semaphore name = __SEMAPHORE_INITIALIZER(name, n)
    > > +
    >
    > Why should this live in semaphore.h?

    I have no preference, but sharing seems to have been better. Do you
    have any recommendations?

    Luis

    \
     
     \ /
      Last update: 2023-03-29 09:53    [W:2.301 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site