mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Armin Schindler <armin@melware.de>
Cc: linux-kernel@vger.kernel.org, torvalds@osdl.org
Subject: Re: [PATCH 2.6] serialization of kernelcapi work
Date: Sat, 20 Mar 2004 11:14:31 -0800	[thread overview]
Message-ID: <20040320111431.4ba002f1.akpm@osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.31.0403201139240.23993-100000@phoenix.one.melware.de>

Armin Schindler <armin@melware.de> wrote:
>
> On Thu, 18 Mar 2004, Andrew Morton wrote:
> > I would suggest that you look at avoiding the global semaphore.  Suppose
> > someone has 64 interfaces or something.  Is that possible?  It might be
> > better to put the semaphore into struct capi_ctr so you can at least
> > process frames from separate cards in parallel.
> >
> > > Is there a better way to do user-context work serialized ?
> >
> > Not really - you've been bitten by the compulsory per-cpuness of the
> > workqueue handlers.
> >
> > You could have a standalone kernel thread or always queue the work onto CPU
> > #0 (the function to do this isn't merged, but exists).  But both these are
> > unscalable.
> >
> > So apart from moving recv_handler_lock into struct capi_ctr I can't think
> > of anything clever.
> 
> I think an atomic counter in the workqueue-function would be more efficient.
> What do you think about this?
> 
> 
> static atomic_t recv_work_count;
> 
> static void recv_handler(void *data)
> {
> 	if (atomic_inc_and_test(&recv_work_count)) {
> 		do {
> 			/* work to do */
> 		} while (!atomic_add_negative(-1, &recv_work_count));
> 	}
> }
> 
> static int __init kcapi_init(void)
> {
> 	atomic_set(&recv_work_count, -1);
> }
> 
> 
> A second call to the recv_handler() just results in an additional loop
> of the first one and the second CPU goes on with its work.

It doesn't need to be a counter - it can simply be a flag.  See how (say)
queue_work() does it.

However you are limiting things so only a single CPU can run `work to do'
at any time, same as with a semaphore.  

  reply	other threads:[~2004-03-20 19:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-18 10:53 Armin Schindler
2004-03-18 20:18 ` Andrew Morton
2004-03-18 20:37   ` Armin Schindler
2004-03-20 10:53   ` Armin Schindler
2004-03-20 19:14     ` Andrew Morton [this message]
2004-03-20 20:15       ` Armin Schindler
2004-03-20 21:05         ` Andrew Morton
2004-03-20 22:20           ` Armin Schindler

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=20040320111431.4ba002f1.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=armin@melware.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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®