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] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 23 Jul 2012 13:06:10 +0200
From:	Vasilis Liaskovitis <vasilis.liaskovitis@...fitbricks.com>
To:	Wen Congyang <wency@...fujitsu.com>
Cc:	isimatu.yasuaki@...fujitsu.com, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org, linux-acpi@...r.kernel.org
Subject: Re: [RFC PATCH] memory-hotplug: Add memblock_state notifier

Hi,

On Mon, Jul 23, 2012 at 05:08:04PM +0800, Wen Congyang wrote:
> > +static int memblock_state_notifier_nb(struct notifier_block *nb, unsigned long
> > +		val, void *v)
> > +{
> > +	struct memory_notify *arg = (struct memory_notify *)v;
> > +	struct memory_block *mem = NULL;
> > +	struct mem_section *ms;
> > +	unsigned long section_nr;
> > +
> > +	section_nr = pfn_to_section_nr(arg->start_pfn);
> > +	ms = __nr_to_section(section_nr);
> > +	mem = find_memory_block(ms);
> > +	if (!mem)
> > +		goto out;
> 
> we may offline more than one memory block.
>
thanks, you are right.

> > +
> > +	switch (val) {
> > +	case MEM_GOING_OFFLINE:
> > +	case MEM_OFFLINE:
> > +	case MEM_GOING_ONLINE:
> > +	case MEM_ONLINE:
> > +	case MEM_CANCEL_ONLINE:
> > +	case MEM_CANCEL_OFFLINE:
> > +		mem->state = val;
> 
> mem->state is protected by the lock mem->state_mutex, so if you want to
> update the state, you must lock mem->state_mutex. But you cannot lock it
> here, because it may cause deadlock:
> 
> acpi_memhotplug                           sysfs interface
> ===============================================================================
>                                           memory_block_change_state()
>                                               lock mem->state_mutex
>                                               memory_block_action()
> offline_pages()
>     lock_memory_hotplug()
>                                                   offline_memory()
>                                                       lock_memory_hotplug() // block
>     memory_notify()
>         memblock_state_notifier_nb()
> ===============================================================================

good point. Maybe if memory_hotplug_lock and state_mutex locks are acquired in
the same order in the 2 code paths, this could be avoided.

> I'm writing another patch to fix it.

ok, I 'll test.
thanks,

- Vasilis
--
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