Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2532336rwb; Fri, 2 Dec 2022 11:03:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf52PH7WtWDvOGqSQRijZdi2UJ/qAx2/OXT65vzSv6CbFmBe6hhmewV7r0ZSNA3jvZ2O3PLA X-Received: by 2002:a17:906:3109:b0:7a0:b505:cae5 with SMTP id 9-20020a170906310900b007a0b505cae5mr62033186ejx.648.1670007819089; Fri, 02 Dec 2022 11:03:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670007819; cv=none; d=google.com; s=arc-20160816; b=m6gekwW3E4Ji59BwJ/3Cu3Gm4/9Q7nOxksfyLad0ZCtjeoehB7XqcyhBfhQFeJsw2H jYk6WEXGznHE4e5jxX4GStU6bSZTTGgocifWOyTsSW3LcXPzVlmM4J8ZJz9mwsbPnChE z0MX1iSPM+WK9Igping/mSdn8Si7u3HZAZ3aZy2RxkX+ntrhteuUIQY0Orv87B5u6lIC dMqlthnzAXOToiVF5MEvYmU5NEJ3o1ShfTr3JcNuf6lm7ubE2sXqJMP+tncR8SIgOoXi encBft1PBoVqM5DmhHEFaa7unLMzk10PW2YFT6c59YnDKWfkLew5JyVwC4wTPuQO/E3X kNKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:to:dkim-signature:dkim-signature:from; bh=K2j1SZM4oUlYwwMJynT0T9xQynq1mOR1/i8Jr4xfZAI=; b=rdqf046oGjbRXu1J4LAOp26FPgKzsX6E/vzBf10OqDDQXQ3vQMEyXmzgUa9moUWy/u VwBLpkZDzB1WTM5giQHFYXLxvKp87/463snuq0zHWeEY0abFwC/lThlHVNg++utLYbkf /hcWIJP2yBpDsB77Da8kbLS0EPyUmWk/Mqt4eCArACikqdi+fYHvC5SuLYt7/SmNDVqk f+JUuF2SP3pVi4lDAQ2PTqXka32Wb4p+rovafI/5vmMrOmF+f8bkaYwMkzTAf724Pp16 NlE8ujhLgDrZpxu4YsHsdObEA1JaeosIl81Vu2rN3jbs4xVqEuaogXoDBuB4ElzdzC6F eHew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ljR13D0G; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="Dg/DGD+A"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e6-20020a056402190600b00468cd2ab847si6943231edz.172.2022.12.02.11.03.19; Fri, 02 Dec 2022 11:03:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ljR13D0G; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="Dg/DGD+A"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234261AbiLBSsX (ORCPT + 82 others); Fri, 2 Dec 2022 13:48:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233073AbiLBSsU (ORCPT ); Fri, 2 Dec 2022 13:48:20 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B198F8B3A6 for ; Fri, 2 Dec 2022 10:48:19 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1670006897; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=K2j1SZM4oUlYwwMJynT0T9xQynq1mOR1/i8Jr4xfZAI=; b=ljR13D0G4DN1u5TsdK0h1i/8z0NwLjdw+nSj0/qT1Tlwxi6d9DnsShRi+2uifQ2uWKcQtF qlgd9D+BoAtYpzuVFzADQsrJW2pjYX/0sVc5mI7iQCfLqfW+D37BZL4QlX3fbMw9uzJiar zAbVWYRZgceJYU1r3H6vHm1LjGvmSZDR6vBuoOHzHUmGVVwKiOHVffqrF/WWB8dzh1O7gM 0K2UiORvwp2vi7Rl6nsxNutTv9k0kiuUVppkKS14uB1/gwv6G1iXkUSCBQf6RL22K+0K5u xN521DILnAjkbG2aRTzIGLBc6cDx+fIv0d+zbQfn3yLzun4G14oH9IIH9+FGCw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1670006897; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=K2j1SZM4oUlYwwMJynT0T9xQynq1mOR1/i8Jr4xfZAI=; b=Dg/DGD+AXnLEYc/XTYzWsCPDJOp98aDmxx9+Im2rofZTPTU9nOnVAWg4E03EwjVmnPO/U5 WVheFDX/4+mSpZBQ== To: lirongqing@baidu.com, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, peterz@infradead.org, tony.luck@intel.com, wyes.karny@amd.com, linux-kernel@vger.kernel.org, rafael.j.wysocki@intel.com Subject: Re: [PATCH][RFC] x86: override prefer_mwait_c1_over_halt to avoid loading cpuidle-haltpoll driver In-Reply-To: <1669952252-32710-1-git-send-email-lirongqing@baidu.com> References: <1669952252-32710-1-git-send-email-lirongqing@baidu.com> Date: Fri, 02 Dec 2022 19:48:16 +0100 Message-ID: <87fsdxprpr.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Li! On Fri, Dec 02 2022 at 11:37, lirongqing@baidu.com wrote: > From: Li RongQing > > x86 KVM guests with MWAIT can load cpuidle-haltpoll driver, and will > cause performance degradation, so override prefer_mwait_c1_over_halt > to a new value, aviod loading cpuidle-haltpoll driver Neither the subject line nor the above makes any sense to me. prefer_mwait_c1_over_halt() is a function which is invoked and when it returns true then the execution ends up in the code path you are patching. > @@ -889,6 +889,7 @@ void select_idle_routine(const struct cpuinfo_x86 *c) > } else if (prefer_mwait_c1_over_halt(c)) { > pr_info("using mwait in idle threads\n"); > x86_idle = mwait_idle; > + boot_option_idle_override = IDLE_PREF_MWAIT; What you do is setting boot_option_idle_override to a new value, but that has nothing to do with prefer_mwait_c1_over_halt() at all. So how are you overriding that function to a new value? But that's just a word smithing problem. The real and way worse problem is that you pick a variable, which has the purpose to capture the idle override on the kernel command line, and modify it as you see fit, just to prevent that driver from loading. select_idle_routine() reads it to check whether there was a command line override or not. But it is not supposed to write it. Why? Have you checked what else evaluates that variable? Obviously not, because a simple grep would have told you: drivers/cpuidle/cpuidle-haltpoll.c: if (boot_option_idle_override != IDLE_NO_OVERRIDE) drivers/idle/intel_idle.c: if (boot_option_idle_override != IDLE_NO_OVERRIDE) Congratulations! Your patch breaks the default setup of every recent Intel system on the planet because it not only prevents the cpuidle-haltpoll, but also the intel_idle driver from loading. Seriously. It's not too much asked to do at least a simple grep and look at all _nine_ places which evaluate boot_option_idle_override. Thanks, tglx