All of lore.kernel.org
 help / color / mirror / Atom feed
* A udev rule to serve the change event of ACPI container?
@ 2017-06-26  6:26 joeyli
  2017-06-26  8:59 ` Michal Hocko
  2017-06-28 19:53 ` YASUAKI ISHIMATSU
  0 siblings, 2 replies; 27+ messages in thread
From: joeyli @ 2017-06-26  6:26 UTC (permalink / raw)
  To: linux-acpi
  Cc: linux-kernel, Rafael J. Wysocki, Yasuaki Ishimatsu, Michal Hocko

Hi all,

If ACPI received ejection request for a ACPI container, kernel
emits KOBJ_CHANGE uevent when it found online children devices
below the acpi container.

Base on the description of caa73ea15 kernel patch, user space
is expected to offline all devices below the container and the
container itself. Then, user space can finalize the removal of
the container with the help of its ACPI device object's eject
attribute in sysfs.

That means that kernel relies on users space to peform the offline
and ejection jobs to acpi container and children devices. The
discussion is here:
	https://lkml.org/lkml/2013/11/28/520

The mail loop didn't explain why the userspace is responsible for
the whole container offlining. Is it possible to do that transparently
from the kernel? What's the difference between offlining memory and
processors which happends without any cleanup and container which
does essentially the same except it happens at once? 
 
 - After a couple of years, can we let the container hot-remove
   process transparently?
 - Except udev rule, does there have any other mechanism to trigger
   auto offline/ejection?

The attached patch is a udev rule that it's used to perform the
offlien/ejection jobs on user space. I want to send it to systemd.

Thanks a lot!
Joey Lee

>From 6c95d4858e0e7c280e490491c1a00c1b5226a029 Mon Sep 17 00:00:00 2001
From: "Lee, Chun-Yi" <jlee@suse.com>
Date: Mon, 26 Jun 2017 11:40:03 +0800
Subject: [PATCH] rules: handle the change event of ACPI container

Currently the ACPI in kernel emits KOBJ_CHANGE uevent when there
have online children devices below the acpi container.

Base on the description of caa73ea15 kernel patch, user space
is expected to offline all devices below the container and the
container itself. Then, user space can finalize the removal of
the container with the help of its ACPI device object's eject
attribute in sysfs.

This udev rule can be a default user space application to meet
kernel's expectations. This rule walks through the sysfs tree
to trigger the offline of each child device then ejects the
container.

The ACPI_CONTAINER_EJECT environoment variable can be used to
turn off the the ejection logic of container if the ejection
will be triggered by other ways, e.g. BIOS or other user space
application.

Reference: https://lkml.org/lkml/2013/11/28/520
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Michal Hocko <mhocko@suse.cz>
Signed-off-by: "Lee, Chun-Yi" <jlee@suse.com>
---
 rules/80-acpi-container-hotremove.rules | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 rules/80-acpi-container-hotremove.rules

diff --git a/rules/80-acpi-container-hotremove.rules b/rules/80-acpi-container-hotremove.rules
new file mode 100644
index 000000000..ef4ceb5fb
--- /dev/null
+++ b/rules/80-acpi-container-hotremove.rules
@@ -0,0 +1,16 @@
+# do not edit this file, it will be overwritten on update
+
+SUBSYSTEM=="container", ACTION=="change", DEVPATH=="*/ACPI0004:??", ENV{ACPI_CONTAINER_EJECT}="1"\
+RUN+="/bin/sh -c ' \
+if [ $(cat /sys/$env{DEVPATH}/online) -eq 1 ]; then \
+        find -L /sys/$env{DEVPATH}/firmware_node/*/physical_node* -maxdepth 1 -name online | \
+        while read line; do \
+                if [ $(cat $line) -eq 1 ]; then \
+                        /bin/echo 0 > $line; \
+                fi \
+        done; \
+        /bin/echo 0 > /sys/$env{DEVPATH}/online; \
+        if [$env{ACPI_CONTAINER_EJECT} -eq 1] && [ $(cat /sys/$env{DEVPATH}/online) -eq 0 ]; then \
+                /bin/echo 1 > /sys/$env{DEVPATH}/firmware_node/eject; \
+        fi \
+fi'"
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2017-08-15 10:04 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-26  6:26 A udev rule to serve the change event of ACPI container? joeyli
2017-06-26  8:59 ` Michal Hocko
2017-07-11  8:25   ` Michal Hocko
2017-07-13  6:58     ` joeyli
2017-07-13  7:06       ` Michal Hocko
2017-07-13 12:45         ` joeyli
2017-07-14  8:37           ` Michal Hocko
2017-07-14 14:44             ` joeyli
2017-07-17  9:05               ` Michal Hocko
2017-07-19  9:09                 ` joeyli
2017-07-24  8:57                   ` Michal Hocko
2017-07-24  9:29                     ` joeyli
2017-07-25 12:48                       ` Michal Hocko
2017-07-31  7:38                         ` joeyli
2017-08-02  9:01                           ` Michal Hocko
2017-08-03  9:22                             ` joeyli
2017-08-03  9:31                               ` Michal Hocko
2017-08-03  9:52                                 ` joeyli
2017-08-03 11:25                                   ` Michal Hocko
2017-07-23  9:18               ` joeyli
2017-08-01 19:21                 ` YASUAKI ISHIMATSU
2017-08-02  5:49                   ` joeyli
2017-08-03 15:37                     ` YASUAKI ISHIMATSU
2017-08-04 15:06                       ` Michal Hocko
2017-08-15 10:04                         ` joeyli
2017-06-28 19:53 ` YASUAKI ISHIMATSU
2017-06-29  3:57   ` joeyli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.