Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1990101imm; Tue, 22 May 2018 12:45:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpqPpgRrDGVtDAZ/qvuzr/IT6nvLNnMtz+JOA6BV0WuyBwq5HJMs0R7RoZbnDkwjroVFbdS X-Received: by 2002:a62:6e88:: with SMTP id j130-v6mr25276483pfc.111.1527018327037; Tue, 22 May 2018 12:45:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527018327; cv=none; d=google.com; s=arc-20160816; b=hJMx6cJlXK5e0BAqNLGJ5Q114actbyHjTFY7CsRds12nBZbToMEQUo2mN1i5ZyXxfR zhkZG9siksJPigqe9zfJCahH+QLiGyRMuSIjAVpitsM3gtoT2WISFa8mWwvWg2F5W/e3 Uo8uJymGMB41+CNRxuHzgIddbAkslUrn7vZtOQMGbK8zXofgtkRdfOmlBROHiLZ6DQ67 uo4NDeZjOOjLsU5hpgNLQKmYA5iwQgdRnpxorpMzGn+x8oBnFPFSbxcewVKwpWhiPPLj +DFMAPOKPxR04fYkt3mCiq5GHit2XccOS7j5JW3tp1eFV2vLqk2ZtxWeInX3wrFSlVZz CFbQ== 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=Ha8xRAqjjfH6lPojlhkyoee+FTT+FOyfz/1Eek1q7E0=; b=j7QCPgkvmxtg4gw75n4p05ftAkcovAFd1vgIh45rxOszIuwQ3i5hyxit4IetuXWzw5 DNe0byrPD15mGnoJgei8tlJFcd/W2+YypxYImwVg2skTNOD2tSCK/0BgWpBXtqgKq9Ae xppH7O3e3vzBjB9xyVlV3esCJXrmlvrSiQxdz9NL4XNrepAjSB1qf3o1HQbXSjZSyE2B xJHlUjWTPTRPuWxE1fVUZCbYSPswM5F16lonxgA1yT0C846qGijf8VoaawB/A1dMb/Rc 8HhaaI1y3NPPIC7f5qKrBG9UlmJfdildHu+bY713JgtIzT7VlO1unRa4hShcLotuT8GK /sHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q/ZZACPt; 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 a96-v6si17143398pla.169.2018.05.22.12.44.59; Tue, 22 May 2018 12:45:27 -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=Q/ZZACPt; 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 S1752740AbeEVTnT (ORCPT + 99 others); Tue, 22 May 2018 15:43:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:52212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751892AbeEVTnS (ORCPT ); Tue, 22 May 2018 15:43:18 -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 72B2D20873; Tue, 22 May 2018 19:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527018198; bh=z6OwQk3ZjMPnyr0wOcgtk8JQQ+SV/KeHLnrmwT3W1es=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Q/ZZACPtgdSvx1rl5kKMFUcFJGrefBmn/cNlZlIdpTZvPcNnvioD/QbZuaG3e5FoC HpHFEj3E1IMpiosquWa132ccC7jgdSovZuvyIv4Fj7Ot3ojQtQzd8Q+hxOwU1UKVE3 VLpj8lfKV5CppsSPG1eT169RYmFhU2ZvSm49j+SI= Date: Tue, 22 May 2018 21:43:00 +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: <20180522194300.GA9656@kroah.com> References: <2da8730575c589eb7303c7b18a2721da40c446e2.1526987654.git.reinette.chatre@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2da8730575c589eb7303c7b18a2721da40c446e2.1526987654.git.reinette.chatre@intel.com> 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 Tue, May 22, 2018 at 04:29:22AM -0700, Reinette Chatre wrote: > @@ -149,6 +151,9 @@ struct pseudo_lock_region { > unsigned int line_size; > unsigned int size; > void *kmem; > +#ifdef CONFIG_INTEL_RDT_DEBUGFS > + struct dentry *debugfs_dir; > +#endif Who cares, just always have this here, it's not going to save you anything to #ifdef the .c code everywhere just for this one pointer. > @@ -174,6 +180,9 @@ static void pseudo_lock_region_clear(struct pseudo_lock_region *plr) > plr->d->plr = NULL; > plr->d = NULL; > plr->cbm = 0; > +#ifdef CONFIG_INTEL_RDT_DEBUGFS > + plr->debugfs_dir = NULL; > +#endif See? Ick. > + 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. > +#ifdef CONFIG_INTEL_RDT_DEBUGFS > + plr->debugfs_dir = debugfs_create_dir(rdtgrp->kn->name, > + debugfs_resctrl); > + if (IS_ERR(plr->debugfs_dir)) { > + ret = PTR_ERR(plr->debugfs_dir); > + plr->debugfs_dir = NULL; > + goto out_region; Ick no, you never need to care about the return value of a debugfs call. You code should never do something different if a debugfs call succeeds or fails. And you are checking it wrong, even if you did want to do this :) > + } > + > + entry = debugfs_create_file("pseudo_lock_measure", 0200, > + plr->debugfs_dir, rdtgrp, > + &pseudo_measure_fops); > + if (IS_ERR(entry)) { > + ret = PTR_ERR(entry); > + goto out_debugfs; > + } Again, you don't care, don't do this. > +#ifdef CONFIG_INTEL_RDT_DEBUGFS > + debugfs_remove_recursive(rdtgrp->plr->debugfs_dir); > +#endif Don't put ifdefs in .c files, it's not the Linux way at all. You can make this a lot simpler/easier to maintain over time if you do not. thanks, greg k-h