Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1113442imm; Wed, 23 May 2018 10:28:30 -0700 (PDT) X-Google-Smtp-Source: AB8JxZowqo7tZ21Vqzx8l4j0mP+PgEA7RIfxGpYKUOMvIRZQJaLhlxeHbBKYe+1buu48AI1AJni2 X-Received: by 2002:a17:902:1566:: with SMTP id b35-v6mr3844086plh.107.1527096510595; Wed, 23 May 2018 10:28:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527096510; cv=none; d=google.com; s=arc-20160816; b=hscHwLY5INSJvNZLQRFGl9epR6y0EQ8/2kiE3ORqyz01sb+xIVjIZGDqHQYVgyJZt3 RrSJnAQSmwxqpNiI/7MFV2B953VXWAu21PjOcjYgWDpBU/4OFU9miZwijOSyZM5lprWH LzBwPfjqNbdqmm07NqwjQh657xdezk8Hf5sRQt3gRuzM6PKhdKHjt496fJe2Pckx+8rX pvOMcnhC3Q+Mzcx83tnZlY4vFcOxFGs8cBb1MuyjGO6r/lM3bjABXqDRFRk9QQsCAjC4 CumsgIyXBZb+MF/+SFYxIMcAG3Ry5zc6/+5IGGd6MYALMqwromteywjCvOYGjMtjZlXZ k6cg== 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:dkim-signature:arc-authentication-results; bh=LOUr2fkHHr8S3rknEOvcZFxzUez9aBlvDM92kGvqFxE=; b=zDLXbnWVwA8ytEARrFCf75mADtRVo8KkBmLG9L6hZPYe8JXxAb3+ruEmvnVZn5ceBU 1mmlXHuPiP6T/8DhRQpGJ6LlghA1wULrUtHhdgRpICSlNFBOhf5Righin9eYEYuGAyZJ kkX4oAX0WcWhb2oIYWLmhOJoteVGNhYc5XVtTgDk+jY1lgTeZhFdBX1whPCxiXdwe29g s1VpXzv0HomQNsc1N5dhZLbGFWszIetbPzaz1uxgaIFJXwVTf5krBVKF8I9k2tveofRM DilTHyoXCE0wJ22LD+T6vDoBno0+/ILxu6LrYmXeFRpCEX5BrBFFy5lgW8DbXomuaJIi 7TSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vO1syB+a; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12-v6si6997238pgs.126.2018.05.23.10.28.15; Wed, 23 May 2018 10:28:30 -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=vO1syB+a; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933855AbeEWR2E (ORCPT + 99 others); Wed, 23 May 2018 13:28:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:36372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933770AbeEWR2D (ORCPT ); Wed, 23 May 2018 13:28:03 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 15BC920848; Wed, 23 May 2018 17:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527096482; bh=hL97Zs9fKqJwq21wt2YKdAkl258aGJkr3+FpnI9cyD4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vO1syB+atVqg+kWLkfic5kJIxwIw8fR6mSMn0iiQBD65b2dWQKj7Rc3m/4oDNVyeF hNoSUsOEprAax7xN4u3jQn3b2RSvWDwkyyRZGhI4iaiRFgu/4XXoZyH4si6nuUi5TC NYnXojHjmUm80/q2z5ZQHIORe53Wxwc3n2oelqoE= Date: Wed, 23 May 2018 19:27:25 +0200 From: Greg KH To: Reinette Chatre Cc: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com, vikas.shivappa@linux.intel.com, gavin.hindman@intel.com, jithu.joseph@intel.com, dave.hansen@intel.com, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V4 34/38] x86/intel_rdt: Create debugfs files for pseudo-locking testing Message-ID: <20180523172725.GA15511@kroah.com> References: <2da8730575c589eb7303c7b18a2721da40c446e2.1526987654.git.reinette.chatre@intel.com> <20180522194300.GA9656@kroah.com> <20180523080501.GA6822@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 23, 2018 at 10:19:41AM -0700, Reinette Chatre wrote: > Hi Greg, > > On 5/23/2018 1:05 AM, Greg KH wrote: > > On Tue, May 22, 2018 at 02:02:37PM -0700, Reinette Chatre wrote: > >> On 5/22/2018 12:43 PM, Greg KH wrote: > >>> On Tue, May 22, 2018 at 04:29:22AM -0700, Reinette Chatre wrote: > >>>> + ret = strtobool(buf, &bv); > >>>> + if (ret == 0 && bv) { > >>>> + ret = debugfs_file_get(file->f_path.dentry); > >>>> + if (unlikely(ret)) > >>>> + return ret; > >>> > >>> Only ever use unlikely/likely if you can measure the performance > >>> difference. Hint, you can't do that here, it's not needed at all. > >> > >> Here my intention was to follow the current best practices and in the > >> kernel source I am working with eight of the ten usages of > >> debugfs_file_get() is followed by an unlikely(). My assumption was thus > >> that this is a best practice. Thanks for catching this - I'll change it. > > > > Really? That's some horrible examples, any pointers to them? I think I > > need to do a massive sweep of the kernel tree and fix up all of this > > crud so that people don't keep cut/paste the same bad code everywhere. > > As you know debugfs_file_get() is a recent addition to the kernel, > introduced in: > commit e9117a5a4bf65d8e99f060d356a04d27a60b436d > Author: Nicolai Stange > Date: Tue Oct 31 00:15:48 2017 +0100 > > debugfs: implement per-file removal protection > > Following this introduction, the same author modified the now obsolete > calls of debugfs_use_file_start() to debugfs_file_get() in commits: > > commit 7cda7b8f97da9382bb945d541a85cde58d5dac27 > Author: Nicolai Stange > Date: Tue Oct 31 00:15:51 2017 +0100 > > IB/hfi1: convert to debugfs_file_get() and -put() > > > commit 69d29f9e6a53559895e6f785f6cf72daa738f132 > Author: Nicolai Stange > Date: Tue Oct 31 00:15:50 2017 +0100 > > debugfs: convert to debugfs_file_get() and -put() > > > In the above two commits the usage of the new debugfs_file_get() > primarily follows the pattern of: > r = debugfs_file_get(d); > if (unlikely(r)) > > Since the author of the new interface used the pattern above in the > conversions I do not think it is unreasonable to find other developers > following suit believing that it is a best practice. Ah, that's where that pattern came from, thanks for finding it. It was a conversion of the "old" api in the IB code that was using likely(), which in a way, did make sense to use (due to the way processors assume 0 is "true") I'll work on cleaning all of these up on my next long plane ride, should give me something to do :) thanks, greg k-h