Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2795813ybi; Sun, 9 Jun 2019 21:27:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/+lJ315C2fXiIxwYGtylDzdXQxL0V+ji5iedgVII8v99MSG1Jym/o/OxBufRr9MTmfRtN X-Received: by 2002:aa7:9104:: with SMTP id 4mr71545124pfh.66.1560140861035; Sun, 09 Jun 2019 21:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560140861; cv=none; d=google.com; s=arc-20160816; b=XGqV3dfzU5vfQ/XVFdS/kZ4in3VM8YoUSnabrD9uTeka2AMOPIaWHNrzelKu4C7XjS y0Lfs7hIaF5q8uI4q7fdw1Q+aeLklEBlhXPiplzfAhPu8IDJDhd7gzAfx93fvk0vHD1O T57FVOhCZt8dHLtu69jRvmdUHAQgkpvsgvVsMKWssCYxFfNHSjkprnJup5dA7b0W1ZUE MY0buk1w87aMMuv7csbTDYI3/toy63WiZ04TRGKWWYqn7d+bHpgsLIWL3jdvfhyd/1dW bOr+d3mSxs0kM/aKY8DM87PciMTBdkfWZ591pQZuBnp18ewjSH8By5C3v960c79VNgDH K9nA== 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:dkim-signature; bh=g3jACQyYFaKRkPf1a6aopgsiPY+Ck2mpw85n1XzaH4g=; b=NklMebZcQpMOT8DAl16nu1uwIv4btPRFUQK3zezMeOL3P09D/F7xkxaz8of6ft3YJl 3XT7FaJD07rFaDZnGYa2rGheQOoM7rOKhSSU4enwBxi9GaYyEUed1/ZsjZdfPdF6+TwH 75fkoMfvOJI29AJU5hTEWyXWKZcDey6qgaxpIe3YACy7dPyYupHjgeeOLbFRwkfSTwXr CxbOO979n9s8xDGKwae7ixjnc6VadOH4q0ecjBfBAPILtpmNUXIDEdozFe44/fo/n77L dIt4kH0LDqpJzHcDOCKv8tAPzz37qoTEfzJxVYX2ZYj8QAGJHY1vodMhWsaYX1n7pNJJ 8Jfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I0H6l5By; 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=pass (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 w12si8643620plp.296.2019.06.09.21.27.26; Sun, 09 Jun 2019 21:27:41 -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; dkim=pass header.i=@kernel.org header.s=default header.b=I0H6l5By; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729223AbfFJE0m (ORCPT + 99 others); Mon, 10 Jun 2019 00:26:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:45646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726070AbfFJE0m (ORCPT ); Mon, 10 Jun 2019 00:26:42 -0400 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C00A520862 for ; Mon, 10 Jun 2019 04:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560140802; bh=lmI0sZejbp2xYhDVjKl/Q5Dwr+bxp2gKalOSjoOpxBg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=I0H6l5ByiM3XzUA3HAdElS2xBnIJ/Qhuf0hAF3geV0QXH9d/5cJBXeurBhV7Bn0e/ wecIUkn/9erAPS6HwBo0O+6VaWddijmAyljW0jKxwEkKj9frmSZGlC+hn68I7stJk7 NQJ78umYFf+kwKgsiFORfSt2SZyhOr4oOvQK6ij8= Received: by mail-wr1-f49.google.com with SMTP id x17so7637923wrl.9 for ; Sun, 09 Jun 2019 21:26:41 -0700 (PDT) X-Gm-Message-State: APjAAAXlyrULHXYSvqlsx5rz7HyLFvlTirvtUfHqdAykBNjdNYSB/xmR QpUEfadt1Zmkn9OWsVFAClIRiqM0SF/fbBazPVVPFw== X-Received: by 2002:adf:cc85:: with SMTP id p5mr27360248wrj.47.1560140800368; Sun, 09 Jun 2019 21:26:40 -0700 (PDT) MIME-Version: 1.0 References: <1559944837-149589-1-git-send-email-fenghua.yu@intel.com> <1559944837-149589-4-git-send-email-fenghua.yu@intel.com> <20190610040449.GB162238@romley-ivt3.sc.intel.com> In-Reply-To: <20190610040449.GB162238@romley-ivt3.sc.intel.com> From: Andy Lutomirski Date: Sun, 9 Jun 2019 21:26:29 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 3/5] x86/umwait: Add sysfs interface to control umwait C0.2 state To: Fenghua Yu Cc: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Ashok Raj , Tony Luck , Ravi V Shankar , linux-kernel , x86 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 Sun, Jun 9, 2019 at 9:14 PM Fenghua Yu wrote: > > On Sat, Jun 08, 2019 at 03:52:03PM -0700, Andy Lutomirski wrote: > > On Fri, Jun 7, 2019 at 3:10 PM Fenghua Yu wrote: > > > > > > C0.2 state in umwait and tpause instructions can be enabled or disabled > > > on a processor through IA32_UMWAIT_CONTROL MSR register. > > > > > > > > +static u32 get_umwait_control_c02(void) > > > +{ > > > + return umwait_control_cached & MSR_IA32_UMWAIT_CONTROL_C02; > > > +} > > > + > > > +static u32 get_umwait_control_max_time(void) > > > +{ > > > + return umwait_control_cached & MSR_IA32_UMWAIT_CONTROL_MAX_TIME; > > > +} > > > + > > > > I'm not convinced that these helpers make the code any more readable. > > The helpers reduce length of statements that call them. Otherwise, all of > the statements would be easily over 80 characters. > > Plus, each of the helpers is called multiple places in #0003 and #0004. > So the helpers make the patches smaller and cleaner. > I was imagining things like: umwait_control_cached &= ~MSR_IA32_UMWAIT_CONTROL_C02; if (whatever condition) umwait_control_cached |= MSR_IA32_UMWAIT_CONTROL_C02; umwait_control_cached &= ~MSR_IA32_UMWAIT_CONTROL_MAX_TIME; umwait_control_cached |= new_max_time; You could save 8 characters by just calling the variable umwait_control.