public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "canquan.shen" <shencanquan@huawei.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: len.brown@intel.com,
	"shemminger@vyatta.com" <shemminger@vyatta.com>,
	"yakui.zhao@intel.com" <yakui.zhao@intel.com>,
	"xiaowei.yang@huawei.com" <xiaowei.yang@huawei.com>,
	hanweidong <hanweidong@huawei.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	linqiangmin@huawei.com, james.chenjiabo@huawei.com
Subject: Re: Re : [PATCH] acpi: Fix hot cpu remove problem on acpi subsystem
Date: Wed, 07 Sep 2011 10:40:08 +0800	[thread overview]
Message-ID: <4E66D988.9070505@huawei.com> (raw)
In-Reply-To: <CAErSpo5owGuYLP2-JR6uJsM+Pqwna+FUB--p4OhjLVAETqYpcw@mail.gmail.com>

On 2011/9/7 2:38, Bjorn Helgaas wrote:
> On Mon, Sep 5, 2011 at 11:48 PM, canquan.shen<shencanquan@huawei.com>  wrote:
>> On 2011/9/6 12:19, Bjorn Helgaas wrote:
>>>>
>>>> 主题: [PATCH] acpi: Fix hot cpu remove problem on acpi subsystem
>>>>
>>>> In Xen virtualization environment, When I used xen tools (xm vcpu-set
>>>> vcpu_number ) to test the vcpu add and remove, I found it is failure on vcpu
>>>> remove, I found the reason is that nothing to do when cpu remove in
>>>> acpi_processor_hotplug_notify function, so I add the code of send the
>>>> OFFLINE message to udev and add the rule of udev. it is ok on vcpu remove.
>>>> Signed-off-by: Shen canquan<shencanquan@huawei.com>
>>>> ---
>>>>   drivers/acpi/processor_driver.c |    2 ++
>>>>   1 files changed, 2 insertions(+), 0 deletions(-)
>>>> diff --git a/drivers/acpi/processor_driver.c
>>>> b/drivers/acpi/processor_driver.c
>>>> index a4e0f1b..a1c564f 100644
>>>> --- a/drivers/acpi/processor_driver.c
>>>> +++ b/drivers/acpi/processor_driver.c
>>>> @@ -677,6 +677,8 @@ static void acpi_processor_hotplug_notify(acpi_handle
>>>> handle,
>>>>                                      "Driver data is NULL, dropping
>>>> EJECT\n");
>>>>                          return;
>>>>                  }
>>>> +
>>>> +               kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
>>>>                  break;
>>>>          default:
>>>>                  ACPI_DEBUG_PRINT((ACPI_DB_INFO,
>>>
>>> The processor driver used to generate ONLINE and OFFLINE messages.  I
>>> removed them with c1815e0740.  According to the changelog, the driver
>>> core still generates KOBJ_ADD and KOBJ_REMOVE events.
>>
>> Thanks for your answer.
>> When I used xen tools (xm vcpu-set vcpu_numer) to reduce the cpu number. I
>> don't found any event . I use the following tool to capture the event:
>> udevadm monitor --env --kernel --udev.
>>
>> If I used xen tools to add the cpu number , udev module will receive the
>> KOBJ_ADD event.
>>
>> In my patch ,It is more fine to replace KOBJ_OFFLINE to KOBJ_REMOVE event .
>
> I don't think we should emit KOBJ_REMOVE from the ACPI processor
> driver.  KOBJ_ADD is emitted by the driver model core
> (device_register() ->  device_add() path), and I think KOBJ_REMOVE
> should also be emitted from the driver model core.
>
> Is acpi_processor_remove() called when you remove a processor?  I see
> a path where it will be called via acpi_eject_store():
>
>      acpi_eject_store
>        acpi_os_hotplug_execute(acpi_bus_hot_remove_device)
>        acpi_bus_hot_remove_device
>          acpi_bus_trim
>            acpi_bus_remove
>              device_release_driver
>                dev->driver->remove (acpi_processor_remove())
>              acpi_device_unregister
>                device_unregister
>                  device_del
>                    kobject_uevent(KOBJ_REMOVE)
>
> but as far as I can tell, this path is only used when we write
> something to the "eject" sysfs file.  I would think we'd want to use
> most of this same path when we hot remove a CPU via the ACPI SCI
> mechanism.
>

Because in my patch will send the KOBJ_REMOVE event to udev module. and 
I write a udev rule like the following:
ACTION=="remove",DRIVER=="processor",SUBSYSTEM=="acpi",RUN+="/bin/bash 
-c 'echo 1 > /sys%p/eject'"
This rule will write "1" to the "eject" sysfs file. and then call 
acpi_eject_store function.

> If you change acpi_processor_hotplug_notify() to use acpi_bus_trim()
> for the removal case, you should get KOBJ_REMOVE events.  Would that
> be enough to make the xen vcpu remove work, or at least get you
> closer?
>

Xen vcpu remove will work if add the acpi_bus_trim() in the 
acpi_processor_hotplug_notify() function.

But I have two question:
1) If acpi processor driver send the KOBJ_REMOVE(or KOBJ_OFFLINE_CPU) to 
udev module. user has a chance to decide to remove or not remove the cpu 
?  The default is remove cpu if user does not write any udev rule .
2) In the acpi_bus_trim function,  the call patch is following:
      acpi_bus_trim
       acpi_bus_remove
         device_release_driver
            dev->driver->remove (acpi_processor_remove())
                acpi_processor_handle_eject
                       cpu_down
          acpi_device_unregister
             device_unregister
                device_del
                  kobject_uevent(KOBJ_REMOVE)

   I think this call patch is not clear, and I think when acpi processor 
driver receive the eject event. at first it send KOBJ_OFFLINE event to 
udev module and udev rule decide to offline or not offline the cpu. and 
if offline cpu  and then acpi processor driver remove the processor 
device(by listen CPU_DEAD event can know the cpu had offlined)
and so I think it is fine if has the following call path:
     acpi_processor_hotplug_notify
         register_hotcpu_notifier
         kobject_uevent(KOBJ_OFFLINE)


and udev rule will offline the cpu
       store_online
          cpu_down
            _cpu_down
	       cpu_notify_nofail (CPU_DEAD event)

and  in acpi processor driver receive CPU_DEAD
      acpi_cpu_soft_notify
           acpi_bus_trim
               acpi_bus_remove
                device_release_driver
                   dev->driver->remove (acpi_processor_remove())
                acpi_device_unregister
                  device_unregister
                      device_del
                         kobject_uevent(KOBJ_REMOVE)


--
canquan.shen

>> btw: how to find changelog of the c1815e0740.
>
> git show c1815e0740
>
> Bjorn
>
> .
>



  reply	other threads:[~2011-09-07  2:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-05  6:22 Re : [PATCH] acpi: Fix hot cpu remove problem on acpi subsystem Shen Canquan
2011-09-06  4:19 ` Bjorn Helgaas
2011-09-06  6:48   ` canquan.shen
2011-09-06 18:38     ` Bjorn Helgaas
2011-09-07  2:40       ` canquan.shen [this message]
2011-09-07  6:57         ` Bjorn Helgaas
2011-09-08  0:21           ` canquan.shen

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=4E66D988.9070505@huawei.com \
    --to=shencanquan@huawei.com \
    --cc=bhelgaas@google.com \
    --cc=hanweidong@huawei.com \
    --cc=james.chenjiabo@huawei.com \
    --cc=len.brown@intel.com \
    --cc=linqiangmin@huawei.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    --cc=xiaowei.yang@huawei.com \
    --cc=yakui.zhao@intel.com \
    /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