Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3072088ybi; Mon, 17 Jun 2019 16:00:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyETQqF/t17jk1AFvfsVS9SlJ7gR5KYxwKX4j88pfSSKI5ZyBG/Jo0wr4i7LPZ6j9+/Ut7x X-Received: by 2002:a17:902:6a4:: with SMTP id 33mr5080297plh.338.1560812437239; Mon, 17 Jun 2019 16:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560812437; cv=none; d=google.com; s=arc-20160816; b=ThgghAwsygF1qSaIXyxRFMimnca8QT12vrpad1BllqJHWbkYMgttlpOKPCz3LyBG84 BOGnNHO/kGiRKVLInv83c8xDBY0oQUIZjqXfQJiRzcrmj66AB2IEjB9/i94MJmBnVOs5 6ZJRgALgJC2g0F8DVQhGUBFGClQuWBNPqaPEzSybDE/Pb9EwhKyiYW3Vs5qCRYDS1FtH owvOL4tnERL8Z/r1b02KPFij0edPF/h3xcZwDt6Menk749q7chrtzkY1fLTwPH5o/3oJ opToR3UOl4KLywCK2Gyow04a51bVzaenMpAibGTrgvxdy/IS+vq+lg1+2PdMBvGI6Wu8 RWQA== 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=rv0jbia+e0mHFwGlZ+JiiYiUX46XkIeteJ32PGE2Hkc=; b=ylOqJ2CNav2vqoVfD9x/JWfsiNkuPcbZ5EouzPBV5o3FcNoc7s6smT0DyGafz2nIFb 1DszUnqxM7U/rQq+P2TzXC0Y/FUDKmHREu62T6bR7okx0R8uI+AWAEJlJgqpFksncVTb kTl8DesMUAX5qG/Z3jROURxgokPew7JKidqeLBQh+LLT17O9KPNdFg8hF5jD7NOykuIS igf1IS2vy0DzBO1FKbN3xj6lkW9pYCEcVkJxxQ/2gQbbihRS7wmei5FmoErCBrmY7LIy hXQPHuFIEYjE8x8ZRp/LCxV0RJzIa4cPVRQbQ0T2GOwuCcLiWqWzP4CqQg+S4Z34diEr JBlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=utoXW3e+; 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 v19si8577903plo.404.2019.06.17.16.00.21; Mon, 17 Jun 2019 16:00:37 -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=utoXW3e+; 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 S1729042AbfFQW7q (ORCPT + 99 others); Mon, 17 Jun 2019 18:59:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:47880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728293AbfFQW7m (ORCPT ); Mon, 17 Jun 2019 18:59:42 -0400 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 196F0208CB for ; Mon, 17 Jun 2019 22:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560812381; bh=yyHCPQUb4n948ybNrizyuEo+sw5dnPT3EY4ArDk9vEw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=utoXW3e+tA/DtyJyMs+sgAuWtOHWNZvdzVE9o+BGFeSIPuXnAsF82zR61O6m0PQT5 CSjNDt5xw7ZRgDIzXUP9YGWphEDXyUc2covZDKOoRFYZm9dqTx8F93ssXnxPeVCgYk YNkyyTpYbo+Terhf4zrO+euPAAUIYHeD9Oaq29FA= Received: by mail-wm1-f43.google.com with SMTP id h19so977133wme.0 for ; Mon, 17 Jun 2019 15:59:41 -0700 (PDT) X-Gm-Message-State: APjAAAWy1FBvLuq2osN6wCCFdro+GtY297qbrUexjBMiqjwVkIasF2KO v2Kj0upJCCG+E8cNH1Ws56joWPx2tru9/7HfQVEBnQ== X-Received: by 2002:a7b:c450:: with SMTP id l16mr673665wmi.0.1560812379691; Mon, 17 Jun 2019 15:59:39 -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> <20190617224820.GD217081@romley-ivt3.sc.intel.com> In-Reply-To: <20190617224820.GD217081@romley-ivt3.sc.intel.com> From: Andy Lutomirski Date: Mon, 17 Jun 2019 15:59:28 -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 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.