lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20080317195301.GL17940@kernel.dk>
Date:	Mon, 17 Mar 2008 20:53:01 +0100
From:	Jens Axboe <jens.axboe@...cle.com>
To:	"Alan D. Brunelle" <Alan.Brunelle@...com>
Cc:	linux-kernel@...r.kernel.org, npiggin@...e.de, dgc@....com
Subject: Re: [Patch (block.git) 2/2] Ensure single IPI generation for SMP call  single

On Mon, Mar 17 2008, Jens Axboe wrote:
> On Mon, Mar 17 2008, Alan D. Brunelle wrote:
> > diff --git a/kernel/smp.c b/kernel/smp.c
> > index 7232e1c..f7ec401 100644
> > --- a/kernel/smp.c
> > +++ b/kernel/smp.c
> > @@ -23,28 +23,34 @@ void __cpuinit generic_init_call_single_data(void)
> >  
> >  void generic_smp_call_function_single_interrupt(void)
> >  {
> > -	struct call_single_queue *q;
> >  	unsigned long flags;
> >  	LIST_HEAD(list);
> > +	struct call_single_queue *q = &__get_cpu_var(call_single_queue);
> >  
> > -	q = &__get_cpu_var(call_single_queue);
> >  	spin_lock_irqsave(&q->lock, flags);
> > -	list_replace_init(&q->list, &list);
> > -	spin_unlock_irqrestore(&q->lock, flags);
> > +	while (!list_empty(&q->list)) {
> > +		list_replace_init(&q->list, &list);
> > +		spin_unlock_irqrestore(&q->lock, flags);
> >  
> > -	while (!list_empty(&list)) {
> > -		struct call_single_data *data;
> > +		do {
> > +			struct call_single_data *data;
> >  
> > -		data = list_entry(list.next, struct call_single_data, list);
> > -		list_del(&data->list);
> > +			data = list_entry(list.next, struct call_single_data,
> > +						list);
> > +			list_del(&data->list);
> >  
> > -		data->func(data->info);
> > -		if (data->flags & CSD_FLAG_WAIT) {
> > -			smp_wmb();
> > -			data->flags = 0;
> > -		} else if (data->flags & CSD_FLAG_ALLOC)
> > -			kfree(data);
> > +			data->func(data->info);
> > +			if (data->flags & CSD_FLAG_WAIT) {
> > +				smp_wmb();
> > +				data->flags = 0;
> > +			} else if (data->flags & CSD_FLAG_ALLOC)
> > +				kfree(data);
> > +		} while (!list_empty(&list));
> > +
> > +		spin_lock_irqsave(&q->lock, flags);
> >  	}
> > +	q->activated = 0;
> > +	spin_unlock_irqrestore(&q->lock, flags);
> >  }
> 
> I agree with doing it this way, re-checking and doing another run (or
> more). However I think we can improve it a bit so we don't always have
> to grab the dst lock at least twice - it should be safe enough to
> include the lock only inside the first loop, doing an smp_mb() before
> the list_empty() check and again at the bottom before looping around and
> doing the list_empty() check again.
> 
> I've rolled a new patch series here:
> 
> http://git.kernel.dk/?p=linux-2.6-block.git;a=shortlog;h=io-cpu-affinity
> 
> (or just pull the io-cpu-affinity branch), it also includes a bunch of
> other cleanups like porting the faster smp_call_function() to ia64 and
> powerpc as well. So the kernel/smp.c generic helpers have grown a bit,
> while the arch bits are smaller.
> 
> I'm curious if it now boots on ia64, since I killed the hack to manually
> call the __init manually there. If you could check, I would appreciate
> it ;-)
> 
> I've built all 4 supported archs and they compile and link fine, but
> nothing has been booted yet.

x86 and x86-64 boot just fine, so powerpc should work as well (will do
performance testing on a 4-way ppc tomorrow). ia64 should also work, as
long as the init_call_single_data() gets called correctly.

If it doesn't work on tha ia64, try and change the core_initcall() to a
postcore_initcall() or even an arch_initcall(). It now resides in
kernel/smp.c.

-- 
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ