Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3514141ybg; Mon, 28 Oct 2019 14:09:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYZ2FdDWnl+Z9Fq1u2mwy0l7xXYIwajZgWSTAd8IDOaF0tFOY6MfA4ze6qQn1cp0iIe+Rw X-Received: by 2002:a05:6402:2c5:: with SMTP id b5mr21973672edx.157.1572296973478; Mon, 28 Oct 2019 14:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572296973; cv=none; d=google.com; s=arc-20160816; b=bbDlPwLE2Un4k6K85csoxbIIWVr8G51a4YwE3+oeYI06p65bHj8TRUTxPSOpXA5WlF P/GxRw8IB8wauSlaUoehVbP0cOUQD0oOJpRvjMe2IdtuW22zZh1nMlDjGxtzZuoCwxFg iQGLqVCDkj1MmReSTjU25SB5P0Xlo0lsAOTmg2dJPSibrypyN6o23f9L/VyHPuSuuBxV uCZwo9ClnGTGGliW+zCkJZh9yrpfJyzcvKZZf2c8sFuqDonoyKhyFr6s+HlA1tcM92ZP oK1uqUJUoW+5M1BKrgUaDwScpmE1leKAjC7KGSTLrG1tyrjozEUcfcF7har/6RUQxrl8 PMmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gLftoG2KkDQfazhG42cT+I3DI/6H1U3RO15S16VJu7E=; b=V78DdZFDoyd8AywRzvZk/8wV4TNE9fXRS28c96xxoC8ertSgP1Pq2wJYs/ZXggWoHC wS3qdqL+chFY1jUGh5/0Qg7Vm7YJ5NCBrXb+G0MCIIrl50kLTKDl5U0zvASHvhYVeIEU KcBPLnt+v/qdwjgzb6bArWVhmoiiBkAmCnEE5bAJLN7SlbKhf6wojeZcqewS4QWRoCTu CbKHhEXskFRbvPGVnFXi62jOWowhRB0sRV+bKEUvcDmJq6QK069UWQYhl1iGYto1diBv d0tGh8cI7rnpx7wIpQw9DmkjtjVbpygnz9NCaf5rpAiZtm8F2/q2LxpOf3eqtBcqbuVm SYkw== 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 t26si7917523edd.184.2019.10.28.14.09.09; Mon, 28 Oct 2019 14:09:33 -0700 (PDT) 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 S1729734AbfJ1PWF (ORCPT + 99 others); Mon, 28 Oct 2019 11:22:05 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:42632 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbfJ1PWF (ORCPT ); Mon, 28 Oct 2019 11:22:05 -0400 Received: from cust-east-parth2-46-193-72-114.wb.wifirst.net (46.193.72.114) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.292) id 5e1bbc9d50f66428; Mon, 28 Oct 2019 16:22:02 +0100 From: "Rafael J. Wysocki" To: Zhenzhong Duan Cc: linux-kernel@vger.kernel.org, daniel.lezcano@linaro.org, linux-pm@vger.kernel.org, mtosatti@redhat.com Subject: Re: [PATCH v2] cpuidle: not unset the driver if it already exist Date: Mon, 28 Oct 2019 16:22:02 +0100 Message-ID: <3207655.LvExCM5pf1@kreacher> In-Reply-To: <1571795834-2027-1-git-send-email-zhenzhong.duan@oracle.com> References: <1571795834-2027-1-git-send-email-zhenzhong.duan@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, October 23, 2019 3:57:14 AM CET Zhenzhong Duan wrote: > __cpuidle_set_driver() check if there is an already exist driver and > unset it before return with -EBUSY. The next call will succeed as it's > just unset. > > check if any of the CPUs in the mask have a driver different from drv > already and if so return -EBUSY before updating any cpuidle_drivers > per-CPU pointers. > > Signed-off-by: Zhenzhong Duan > --- > v2: update code logic per Rafael > > drivers/cpuidle/driver.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c > index 80c1a83..acfce04 100644 > --- a/drivers/cpuidle/driver.c > +++ b/drivers/cpuidle/driver.c > @@ -62,24 +62,23 @@ static inline void __cpuidle_unset_driver(struct cpuidle_driver *drv) > * __cpuidle_set_driver - set per CPU driver variables for the given driver. > * @drv: a valid pointer to a struct cpuidle_driver > * > - * For each CPU in the driver's cpumask, unset the registered driver per CPU > - * to @drv. > - * > - * Returns 0 on success, -EBUSY if the CPUs have driver(s) already. > + * Returns 0 on success, -EBUSY if any CPU in the cpumask have a driver > + * different from drv already. > */ > static inline int __cpuidle_set_driver(struct cpuidle_driver *drv) > { > int cpu; > > for_each_cpu(cpu, drv->cpumask) { > + struct cpuidle_driver *old_drv; > > - if (__cpuidle_get_cpu_driver(cpu)) { > - __cpuidle_unset_driver(drv); > + old_drv = __cpuidle_get_cpu_driver(cpu); > + if (old_drv && old_drv != drv) > return -EBUSY; > - } > + } > > + for_each_cpu(cpu, drv->cpumask) > per_cpu(cpuidle_drivers, cpu) = drv; > - } > > return 0; > } > Applied as 5.5 material, thanks!