Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4159815imu; Mon, 10 Dec 2018 14:14:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/UhwB183BbQxCZy67q1sxci4U5D0jtttUTUfDeSmUAJQKJS8Mj4CJh53yoeVaRa/rS9ii3b X-Received: by 2002:a63:4e41:: with SMTP id o1mr12705590pgl.282.1544480087112; Mon, 10 Dec 2018 14:14:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544480087; cv=none; d=google.com; s=arc-20160816; b=CXZIocfw9+lVZnR5ljemA6EPsM0eawJZmtOAn3IP9/zRjLknU7kqD7jZSlOa9E8Ek7 4or3QpbzVL8gsrAnVtyQ1IeTDrqI/5d+8U/ull/MZDYg5cLAO4agXLEGjp2r5AoqKX7h uWR8dCSpDbxjjjWXVnnAkEEV5BF+Y9RKYpLeCYCpxcCHufXfyz/vDLsppXdow19WeJ0P Mb1qhTYWpuY0jr3PHaaeMe+B39ulRf7FObYAKo7+y5w7t3O3efwVJquAaj6woj4xHJAp JJiNAKE2l4a5f0k+1MDo6XeySmevWfxUDmqdlDZD6I3J2xTedPaJh3UYG0Nt7sFq63DB WhSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=t+LCKtgL9pnOca5dUTl0cje6+MIMZbnz3aBmzWY5fNU=; b=r30LylG3UDygb58HNRcEyNPVxz8aYTQFtHxOPYaWV8ARR7IMTYUEN3mY0sP0gFMN2S Nf4Qccdlz9GzviwrI3qMeVfEFsZ1vP35Kk9TMj8bjTnYfbyYE7gQsd3x2mRmACGQcVBz ld6r2aWLgLnJUlD8AAM8X5s7kH0ELPVMD9TyOxPUsFJtRZQWRqG/xXLQoOHDNHznc+D7 ufFgJH7NDu/e9Hg2eNK82vo3vzC49VI59tKPb5aoZVLBJ7eQ4NPjidI1YVd8LtDjBshH u5y3+2KhRzudvy1VTT9bGpgAtUcIgqNLAxmh09kv8TA9x3rrsSqs8pwXEYMnvBBlyt6M 30JQ== 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 a13si11960524pfd.3.2018.12.10.14.14.32; Mon, 10 Dec 2018 14:14:47 -0800 (PST) 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 S1730159AbeLJVmL (ORCPT + 99 others); Mon, 10 Dec 2018 16:42:11 -0500 Received: from mga17.intel.com ([192.55.52.151]:4805 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727896AbeLJVmK (ORCPT ); Mon, 10 Dec 2018 16:42:10 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2018 13:42:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,339,1539673200"; d="scan'208";a="117241378" Received: from rchatre-mobl.amr.corp.intel.com (HELO [10.24.14.96]) ([10.24.14.96]) by orsmga002.jf.intel.com with ESMTP; 10 Dec 2018 13:42:10 -0800 Subject: Re: [PATCH] x86/resctrl: Fix rdt_find_domain() return value checks To: Borislav Petkov Cc: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com, jithu.joseph@intel.com, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org References: <20181210191311.GC5482@zn.tnic> <40422756-cef4-38b1-8554-c99e7bcb7765@intel.com> <20181210210436.GI5482@zn.tnic> From: Reinette Chatre Message-ID: <3b097a0a-bcc5-1929-eb50-0e251ebc1152@intel.com> Date: Mon, 10 Dec 2018 13:42:10 -0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181210210436.GI5482@zn.tnic> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Boris, On 12/10/2018 1:04 PM, Borislav Petkov wrote: > On Mon, Dec 10, 2018 at 12:42:14PM -0800, Reinette Chatre wrote: >> Would you be ok if the above is changed to >> >> if (id < 0) >> return ERR_PTR(-ENOENT); >> >> as part of this patch? > > Yap. > >> Looking at rdtgroup_mondata_show() is does seem as though ENOENT is the >> actual intended error value, > > #define ENOENT 2 /* No such file or directory */ > >> although ENODEV could perhaps also be considered since such a result >> reflects that a particular cache instance could not be found. > > #define ENODEV 19 /* No such device */ > > Yeah, they both kinda look ok to me and in the end of the day, the thing > that matters most is pinpointing the place in the code which causes the > error. Thank you for the sanity check. I think ENODEV may reflect the issue better and will do so in the next version. This would not affect the current code (quoted below) that subsequently translates the error to ENOENT. > And looking at that particular part: > > r = &rdt_resources_all[resid]; > d = rdt_find_domain(r, domid, NULL); > if (!d) { > ret = -ENOENT; > goto out; > } > > You *could* put in there something like: > > seq_printf(m, "Cannot find a domain for resource ID: %d\n", domid); > > and this way it is perfectly clear which error path it is. > > :-) > From what I understand this scenario should never happen - at the time knowledge of the resource instance is removed then these mondata files referring to it will be removed also. Even so, I'd prefer not to make any user visible changes without a specific requirement or need to do so. In this case ENOENT is the only error code returned during this user space interaction so from what I can tell it is currently clear which error path it is. Reinette