Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3074767ybi; Mon, 17 Jun 2019 16:03:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTVjCllpU55k3H7L6B1JjFumqk0ZiCMNOYqhoibPDSpgTN6ztTpKCDUeRmZYFHQoxMZOBK X-Received: by 2002:a17:902:2a29:: with SMTP id i38mr83082376plb.46.1560812594920; Mon, 17 Jun 2019 16:03:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560812594; cv=none; d=google.com; s=arc-20160816; b=qqkmNxEndopbxdVPg0Wr5JCD7yeT6A7bMJyFCf5QxeyXtlqvjDmzTgUErlhS4G+bgz rIIsIkENk/1F0DAbRjd0BE2mXhl+deiceunIhL+/dvQ7H7y+mbbRa7awh7JoWzCSs778 6fs0MXYMOmA+DbgtkIAo7hLZKrMhAJ8hjbC7Dy4sDZYGmdsFo6cqSnopYph+O63wKI00 eP/s385kVKK7gCV98tESsFltlezmgFgLLh/51r99V5EtPqAuFHE4w1MLaDZhws18hMcM knVgAPbaFwVBSA+gTC+64a2BhNao+ogZelAdI28gBr0SMyfscH+bzK+WJH7/iSjbolNb lsIw== 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; bh=pgSOIzOQCvEdJZOC53vOzM4KwA60/JiqNEsE54/1vRI=; b=zrfZFVM1D4sfOg58ZVZGP8knTOXBbzSsR9qxo8LFerUoDtwQu4o2oBTsiMQ5laRi5d pu+9ji8zm0vgx+HEzLht+biCJXKLvHbIMZL2v5eGTKDsvw++g8AQtnkTC5jZdixShQPN UQlKJlhMYCaU8PwahGGnCu1ynfnxToOmFz1VhPx2hFEB72EBO9a9A7x1UMygU+CHi++p gx/gnYL6Yq+lEsy1d8u2DN5AI/JQ+tlenKvgjnnTff19rP9+vuYXHNo9jAffXyTgnywJ I+wNSDF6TBgXrrJ9KH44FX3EXDj6uNclrqE4YrZrkbi6S9+Rsq/dDVSerEJpnpe0WMPS 33MQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l10si11871088pgk.276.2019.06.17.16.02.59; Mon, 17 Jun 2019 16:03:14 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728589AbfFQXBd (ORCPT + 99 others); Mon, 17 Jun 2019 19:01:33 -0400 Received: from mga14.intel.com ([192.55.52.115]:38492 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726555AbfFQXBd (ORCPT ); Mon, 17 Jun 2019 19:01:33 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jun 2019 16:01:17 -0700 X-ExtLoop1: 1 Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by orsmga006.jf.intel.com with ESMTP; 17 Jun 2019 16:01:17 -0700 Date: Mon, 17 Jun 2019 15:51:46 -0700 From: Fenghua Yu To: Andy Lutomirski Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Ashok Raj , Tony Luck , Ravi V Shankar , linux-kernel , x86 Subject: Re: [PATCH v4 3/5] x86/umwait: Add sysfs interface to control umwait C0.2 state Message-ID: <20190617225146.GE217081@romley-ivt3.sc.intel.com> 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> <20190617224820.GD217081@romley-ivt3.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 17, 2019 at 03:59:28PM -0700, Andy Lutomirski wrote: > On Mon, Jun 17, 2019 at 3:57 PM Fenghua Yu wrote: > > > > On Sun, Jun 09, 2019 at 09:26:29PM -0700, Andy Lutomirski wrote: > > > 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; > > > > How about this statement? > > With the helpers: > > umwait_control_cached = max_time | get_umwait_control_c02(); > > If there is no helpers, the above statement will need two statements: > > umwait_control_cached &= ~MSR_IA32_UMWAIT_CONTROL_MAX_TIME; > > umwait_control_cached |= max_time; > > > > Another example: > > With the helpers: > > if (umwait_control_c02 == get_umwait_control_c02()) > > If no helpers, the above statement will be long: > > if (umwait_control_c02 == (umwait_control_cached & MSR_IA32_UMWAIT_CONTROL_C02_DISABLED)) > > > > There are quite a few places like above examples. > > > > The helpers can reduce the length of those long lines and make code more > > readable and shorter, right? > > > > Can I still keep the helpers? > > > > Sure, unless someone else objects. Thank you very much for your advice! -Fenghua