Received: by 10.223.185.116 with SMTP id b49csp133525wrg; Fri, 2 Mar 2018 15:13:27 -0800 (PST) X-Google-Smtp-Source: AG47ELv8v+wKE6t1NOlEcJVWKFvbdtlJWh5aNelBMz9y+ZLH7n313yJ7RmuBAvZbklihie+nS59G X-Received: by 2002:a17:902:8f89:: with SMTP id z9-v6mr6751259plo.370.1520032407492; Fri, 02 Mar 2018 15:13:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520032407; cv=none; d=google.com; s=arc-20160816; b=TDWEQ3ShkRimaVdtA6Co/ujRmZ1fcG+e3KmDuWf0ktwNswz2YwUEvsez9GoqP3lHu5 8NJ9ZJx8Bth3qhQrZdB60I+z7IljY/RagzTw8jmRPrQER8JVkTxZsZ1zlM3loYVWbx6N HB5wwEnqid1hf0IT3X5+a6eDAHz8tFkzuiyGWOxlLQX/75aAVZZn+/1cuMEmA9HzY/8i 3sHev5IH9LtVLWVpGZlLI5A7sI8daQ9xz8No+D7FTtZ+z75Nk3eCzVZoDt7wbJ8+7GFQ KIMnlMiQ0ipJY16w5K9SQwRs1R0T1tQHCbPZE4T/cjGFOYCNqAxZi/r/GbJajgLkEocp ODfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=ezhRY6iE5IycrA+gYSvNG3xVpfDfvfYpxxWpfG1fOP4=; b=GgBE8xxaya3IR+R3bZG4Jn3dJivyI+3w0d+OnkfcCiX4M4B7aJw7gBgj+qGE4cmBS+ vlz/KLC5cCeR2kwgalFeUuj8cuGTj5/NOhZWTLx1Aoa8x3Jqt3EW5jl8/PU3JBsV3rZJ P/DyQwYwjh4aClxttaZv9zdyHWr1LtCEKhbG1hyzEhWye5oqW62mmF64tJC0vUkgoxMd JER2BmAT8m1XNzbiJUWrofmG6cunt/zsqpmYP7s5jx+s+Dx8D5g/aNPHEKTxfmrX3e0Z GVc9ZC6wk7/eFIrO4Q124QbB7kA61IE9c/vqA3X0L3hR06+52DJFRAz2M2JuC3fAFbp3 5tOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17-v6si5362850plo.535.2018.03.02.15.13.12; Fri, 02 Mar 2018 15:13:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1427155AbeCBPKq (ORCPT + 99 others); Fri, 2 Mar 2018 10:10:46 -0500 Received: from smtp.nue.novell.com ([195.135.221.5]:36070 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1427101AbeCBPKl (ORCPT ); Fri, 2 Mar 2018 10:10:41 -0500 Received: from linux-l9pv.suse (124-11-22-254.static.tfn.net.tw [124.11.22.254]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Fri, 02 Mar 2018 16:10:34 +0100 Date: Fri, 2 Mar 2018 23:10:22 +0800 From: joeyli To: Michal Hocko Cc: "Lee, Chun-Yi" , "Rafael J . Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Len Brown Subject: Re: [PATCH] ACPI / scan: Send the change uevent with offine environmental data Message-ID: <20180302151022.GB6140@linux-l9pv.suse> References: <20180302063508.15818-1-jlee@suse.com> <20180302140059.GA12772@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180302140059.GA12772@dhcp22.suse.cz> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 02, 2018 at 03:00:59PM +0100, Michal Hocko wrote: > On Fri 02-03-18 14:35:08, Lee, Chun-Yi wrote: > > In current design of ACPI container offline, Kernel emits > > KOBJ_CHANGE uevent to user space to indidate that the ejection of > > the container was triggered by platform. (caa73ea15 patch) > > > > A pure KOBJ_CHANGE uevent is not enough for user space to identify > > the purpose. For example, a "udevadm trigger" command can also > > be used to emit change event to all udev rules. A udev rule can not > > identify that the event is from kernel for offline or from udevadm > > for other purpose. Then the offline action in udev rule may also be > > triggered by udevadm tool. > > > > So, similar to the change uevent of dock, kernel sends the > > KOBJ_CHANGE uevent with a offline environmental data to indicate > > purpose. It's useful by udev rule for using ENV{EVENT} filter. > > Looks reasonable to me. I have also tested this on Huawei Kunlun server > which hits the offline & online storm as a result of udevadm triggered > and a container udev rule which hooks into change event and offlines > all devices attached to the container. This patch allowed the udev rule > to be more targeted at the offline event. > > > Cc: Michal Hocko > > Cc: "Rafael J. Wysocki" > > Cc: Len Brown > > Signed-off-by: "Lee, Chun-Yi" > > Acked-by: Michal Hocko > Tested-by: Michal Hocko > Thank you for review and testing. Joey Lee > > --- > > drivers/acpi/scan.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > > index 8e63d93..f6dca9b 100644 > > --- a/drivers/acpi/scan.c > > +++ b/drivers/acpi/scan.c > > @@ -116,6 +116,7 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent) > > { > > struct acpi_device_physical_node *pn; > > bool offline = true; > > + static const char *envp[] = { "EVENT=offline", NULL }; > > > > /* > > * acpi_container_offline() calls this for all of the container's > > @@ -126,7 +127,7 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent) > > list_for_each_entry(pn, &adev->physical_node_list, node) > > if (device_supports_offline(pn->dev) && !pn->dev->offline) { > > if (uevent) > > - kobject_uevent(&pn->dev->kobj, KOBJ_CHANGE); > > + kobject_uevent_env(&pn->dev->kobj, KOBJ_CHANGE, envp); > > > > offline = false; > > break; > > -- > > 2.10.2 > > -- > Michal Hocko > SUSE Labs