Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5386932imm; Tue, 19 Jun 2018 09:34:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIQcZ7PQnsWMcyor4q3I4Kl+PR+Tu6GPKjJTKvNTypZUPVLaYNMa9TJhX4VDBsygpoB7yaG X-Received: by 2002:a63:86c8:: with SMTP id x191-v6mr15212088pgd.2.1529426085407; Tue, 19 Jun 2018 09:34:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529426085; cv=none; d=google.com; s=arc-20160816; b=ogBZUbAysbgO3RWSIpuHPMbGMKvsK91fPoRwN71x6me+xwj4BFgTqjd3aDU34RVfmV t8slsxiO8lfRvil6NrG49S32zqbtb8cONZhngpWgtU3STzHz+9d1g9KTVZuVKW8Qimrt Almsi33drqxsBQmRz/OfjmEgJgkAGHHlkNo6CTRvsHZCJA1McAPffxHG8MoacOwaAa42 HlXGcLyxRGgpN4cqCQ+uE4NY3C5fmbZvlLz8Hl9pPpdIlk+6b0WqayccznoJdOKKGZUs ggT7g0fI5Sx5BOC9KJKCxCthnAwoIV/sCtIezd7foy6FLIzXGZ0jiQeEmIl6c5W32/6J UyCA== 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:arc-authentication-results; bh=sflvbSNIcZx4RuOuKJYedEjupu823v4FmmcEWrmXKbs=; b=w3tlHm1Vv/Ilg+rxnWCUED0wFYEMFHeM6dtuOecufE3ZwhrFgRfseWmsswSKUQGp7K ggPStlAERv5LQqoFjevKiwzuKElogpHZyxyOcmX3WcJ3Km2gmkEPVJWE8w5+r8+6WhnY IFD1Jf4APJg36UeGKnkfFpvvK0hNAuGixZ1IPn44llUzgH0XOkgnLQFwV4ZSN33lgtHL QDvwFrQkJ11B/eV8wo8JH7ufxTR3GiHPaQ0FGHBypFF/zAhLjHLxPud8GarrJQtjpTHf MKjOGy/amsEJ8CgNjZj5Wr3CuHRLfmcVrmDjHYi0vyom121I2iUqN+8xm45+D/WCTFgt Dmmw== 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 v75-v6si2256pfd.71.2018.06.19.09.34.30; Tue, 19 Jun 2018 09:34:45 -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 S967044AbeFSQdd (ORCPT + 99 others); Tue, 19 Jun 2018 12:33:33 -0400 Received: from mga04.intel.com ([192.55.52.120]:65523 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966368AbeFSQdc (ORCPT ); Tue, 19 Jun 2018 12:33:32 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jun 2018 09:33:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,243,1526367600"; d="scan'208";a="48287789" Received: from rchatre-mobl.amr.corp.intel.com (HELO [10.24.14.129]) ([10.24.14.129]) by fmsmga007.fm.intel.com with ESMTP; 19 Jun 2018 09:33:31 -0700 Subject: Re: [PATCH V6 07/38] x86/intel_rdt: Initialize new resource group with sane defaults To: Thomas Gleixner Cc: 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 References: <68030110df15615d95731fd354ff7adfb0476d37.1527593970.git.reinette.chatre@intel.com> <44af4ecef879e88ec1b74c5decbf5dccaf998866.1528405422.git.reinette.chatre@intel.com> From: Reinette Chatre Message-ID: Date: Tue, 19 Jun 2018 09:33:30 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: 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 Thomas, On 6/19/2018 5:31 AM, Thomas Gleixner wrote: > On Thu, 7 Jun 2018, Reinette Chatre wrote: >> +/** >> + * cbm_ensure_valid - Enforce validity on provided CBM >> + * @_val: Candidate CBM >> + * @r: RDT resource to which the CBM belongs >> + * >> + * The provided CBM represents all cache portions available for use. This >> + * may be represented by a bitmap that does not consist of contiguous ones >> + * and thus be an invalid CBM. >> + * Here the provided CBM is forced to be a valid CBM by only considering >> + * the first set of contiguous bits as valid and clearing all bits. >> + * The intention here is to provide a valid default CBM with which a new >> + * resource group is initialized. The user can follow this with a >> + * modification to the CBM if the default does not satisfy the >> + * requirements. >> + */ >> +static void cbm_ensure_valid(u32 *_val, struct rdt_resource *r) >> +{ >> + unsigned long *val = (unsigned long *)_val; > > I'm a bit worried about the u32 to unsigned long case here. I know that > cbm_len cannot exceed 32, but still. At least it wants a comment. Will do. I am planning to add the following to the next version. -->8-- diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index bef736f6ba2f..7b4a09d81a30 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -2285,6 +2285,14 @@ static int mkdir_mondata_all(struct kernfs_node *parent_kn, */ static void cbm_ensure_valid(u32 *_val, struct rdt_resource *r) { + /* + * Convert the u32 _val to an unsigned long required by all the bit + * operations within this function. No more than 32 bits of this + * converted value can be accessed because all bit operations are + * additionally provided with cbm_len that is initialized during + * hardware enumeration using five bits from the EAX register and + * thus never can exceed 32 bits. + */ unsigned long *val = (unsigned long *)_val; unsigned int cbm_len = r->cache.cbm_len; unsigned long first_bit, zero_bit; Reinette