Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5924454ybg; Tue, 22 Oct 2019 10:19:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPl43NPmyh/GZn1/ZqmjpmzKyN9wHzqwzpU9WnBN4bCD6Vb6gxh2AiV7hpmXaC5R/yxL63 X-Received: by 2002:a50:8dc9:: with SMTP id s9mr17075018edh.168.1571764767563; Tue, 22 Oct 2019 10:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571764767; cv=none; d=google.com; s=arc-20160816; b=PUSQBtXBPwVojFvAJo/54bkSvveTn+HrdRG6la1rmtiTsYSBz5AutOLtWwJZMWsxs2 49Qh40txcrEoO7Auol5SMIMk7Ro0jsvXIq7X2rlQlzu5EgGEqNFibw81b/vC4dWN8M4n 0gdRb0LZ5Ud1BuJCKgNEsD9YmBswTn0WnPla8PgghhiFAcL+8Yf3OG7MRDDrcwQNyUn5 KHl38/J25c1yupqh0bPTKM9kaHPmFy1LY2F5UbCuFKJpmnDJdOvHdzS/O+2UGd3Pgs7P zOC378MTg4zKSVXQX/gMyx0mclT0R5JFcUNvqEWwEd+3jQIa344fl3P6A+bJI7hRZdTW 1Ubg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=oZAk62VktTsx+Ob5O9T/IcWukBxIKCSIlZ2KMfpKjSc=; b=UJJJI7POJ4abpxxC8QLVJgPKTA4TUB91c/1YxnSM8jyviSj7bnpuysws0jBsARFx8Z alPuiiKF8ZqOLmHYhb1ISjP1d3Y9vidxLXBdM+ARj3Rl7mf4LpoRiqXsMNgbLSUwhN8m ByO9suTQ4fEaLi5mlUMORa6q8dQUZsbgsGnUFtHw+iC/OcFAK+RAFKmaAuFHuGjed3xl SjqsMFE3WeS8EWbKV78zmLYaImnxhKC2KFyRGcoCOlLDQbzLFzeOoJlrEbeIyHEUQgZl l47W5Kvg1MlhZ5bViAdeKCPMzIErztvQU0B9XdtnLTEd3MKzk65FwexrBgnfFxjCZe8x 8EbQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6si11296059ejf.8.2019.10.22.10.19.03; Tue, 22 Oct 2019 10:19:27 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730619AbfJVQfo (ORCPT + 99 others); Tue, 22 Oct 2019 12:35:44 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:37434 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725827AbfJVQfo (ORCPT ); Tue, 22 Oct 2019 12:35:44 -0400 Received: by mail-ot1-f68.google.com with SMTP id 53so3139983otv.4; Tue, 22 Oct 2019 09:35:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oZAk62VktTsx+Ob5O9T/IcWukBxIKCSIlZ2KMfpKjSc=; b=Tq4KtB0FuMuoXmcUzSundCvbSJdQdrRbgdQQQDuSY6CoyeUiVeFxew5RMZl1dEt7n4 SOo27ORB/aukXzehw0h/Xof7eu/iBlt8LuspsyTaQO0gkzmmd8D3iEtBbAl6CkQjbCC/ wm4Sfg35sZhYOXYLrXLKmGRQXSeTPfxSZhXmwveV8wOjt52DBjAulV1pJllMJ+6QHsqy mWLflW0VWNJHoTQhLs86iP4TJj2NKgqKAk5/q7MCtkKP6UbwpCaEGrdEYDVVbui8Ix6K r3YQ41reM9wVWZdVFAjBa2gTkti+IbBm5aefJFNRYp5jda1Kw2O1Tjy7OjsQHrpIAJlR AoSg== X-Gm-Message-State: APjAAAUgkZX3ljNkwdCUc5bo76sp4dLNLeiCmzpJzpa7D7twD2qz1P9k VxBj2G/xH5G3EalSYYTwzzisYHi85bCzFl4nUMk= X-Received: by 2002:a9d:5907:: with SMTP id t7mr3368476oth.118.1571762142513; Tue, 22 Oct 2019 09:35:42 -0700 (PDT) MIME-Version: 1.0 References: <1570927586-12023-1-git-send-email-zhenzhong.duan@oracle.com> In-Reply-To: <1570927586-12023-1-git-send-email-zhenzhong.duan@oracle.com> From: "Rafael J. Wysocki" Date: Tue, 22 Oct 2019 18:35:31 +0200 Message-ID: Subject: Re: [PATCH] cpuidle: not unset the driver if it already exist To: Zhenzhong Duan Cc: Linux Kernel Mailing List , "Rafael J. Wysocki" , Daniel Lezcano , Linux PM , Marcelo Tosatti Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 14, 2019 at 2:43 AM 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. This is strange as we should either keep old driver and > return -EBUSY or unset and set new driver and return 0. > > Signed-off-by: Zhenzhong Duan > --- > drivers/cpuidle/driver.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c > index 80c1a83..a200304 100644 > --- a/drivers/cpuidle/driver.c > +++ b/drivers/cpuidle/driver.c > @@ -74,7 +74,6 @@ static inline int __cpuidle_set_driver(struct cpuidle_driver *drv) > for_each_cpu(cpu, drv->cpumask) { > > if (__cpuidle_get_cpu_driver(cpu)) { > - __cpuidle_unset_driver(drv); > return -EBUSY; > } There is a bug here, but it needs to be fixed differently. The function should check if any of the CPUs in the mask have a driver (which is different from drv) already and if so return -EBUSY before updating any cpuidle_drivers per-CPU pointers.