Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp642042imm; Fri, 5 Oct 2018 09:22:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV60yjlxO51Gj74+Xd8qWKzu7wUAKF6l+m22h3J1ZUW1ovfuUOupy9knnZj/kh1+yZThHLj3h X-Received: by 2002:a62:d110:: with SMTP id z16-v6mr12970278pfg.229.1538756526180; Fri, 05 Oct 2018 09:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538756526; cv=none; d=google.com; s=arc-20160816; b=Hzkdyns1+Sxj3NkhakylSMbydCWpRoUce9CL1MusK5D570XPsF93R+VwuwwZ7TXmOq 2vaKZn52NlZ635WUDK7sNDmUDMFThUEZvbHkZdFkS9Yx/0ORx3oOz2vnzvaKzjrnKELR 9nTznEs6EGb09NrXSCmoSrpcj33fNbW6sW1z9WXfVqb7upy7UlaJwtszM1QS7D4IO0D1 os5Kfb0cimKALAKVS8MewwTvSfGFKwV6kuu1d5IZKeyoehRUx00PJNCwRVym82TB/fXY pdiD4w2IDefCuiK0Td3F+8k9KZ3UalxgyOgraATfZUdWjKuyUalGg/xSkH4ySyqoIXiN qogA== 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=T0pKxd/js/4GQbEjk0wpuzQJPrgwTdHjCDq/g0m98X0=; b=A+pfR27EHqP11ukRDZT/y9i2d+YhN5zNiliOxweoMHDjgVhvZ/3Oj6FFaGocgaZGIY g7aOYedJTw2U8Ns8rPr2Y4/e1B3P9w/0e/KkdF034o5L3E0sS44K34Fp+DBx7ZwbgUd9 tqKlDPIYbRpeLBDspBrcebycEf/0PDu4XQLbOnqz53SoZiQA2AWfM3JM56YDuMLWZo5x RsMw801aqi/S/dbRm8SE79Rr6xScfDq9r5C/14/F7zghb9u5RzYbKY71J5Ewl8tZaDgN vDoJYpCtBre40AdI2UCi2XDscatYXWJVwIKjMBJ1q/1xUeIcTEQ6wokdYBnR0TUVy/t9 cEHw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15-v6si9931150plk.356.2018.10.05.09.21.50; Fri, 05 Oct 2018 09:22:06 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730242AbeJEXUS (ORCPT + 99 others); Fri, 5 Oct 2018 19:20:18 -0400 Received: from foss.arm.com ([217.140.101.70]:54782 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729669AbeJEXUR (ORCPT ); Fri, 5 Oct 2018 19:20:17 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5149BED1; Fri, 5 Oct 2018 09:20:53 -0700 (PDT) Received: from [10.4.12.81] (melchizedek.emea.arm.com [10.4.12.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E66143F5D3; Fri, 5 Oct 2018 09:20:47 -0700 (PDT) Subject: Re: [RFC PATCH 10/10] arch/x86: Introduce QOS feature for AMD To: "Moger, Babu" Cc: "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "fenghua.yu@intel.com" , "reinette.chatre@intel.com" , "vikas.shivappa@linux.intel.com" , "tony.luck@intel.com" , "x86@kernel.org" , "peterz@infradead.org" , "pombredanne@nexb.com" , "gregkh@linuxfoundation.org" , "kstewart@linuxfoundation.org" , "bp@suse.de" , "rafael.j.wysocki@intel.com" , "ak@linux.intel.com" , "kirill.shutemov@linux.intel.com" , "xiaochen.shen@intel.com" , "colin.king@canonical.com" , "Hurwitz, Sherry" , "Lendacky, Thomas" , "pbonzini@redhat.com" , "dwmw@amazon.co.uk" , "luto@kernel.org" , "jroedel@suse.de" , "jannh@google.com" , "dima@arista.com" , "jpoimboe@redhat.com" , "vkuznets@redhat.com" , "linux-kernel@vger.kernel.org" References: <20180924191841.29111-1-babu.moger@amd.com> <20180924191841.29111-11-babu.moger@amd.com> From: James Morse Message-ID: <81d5c963-0f00-29fa-2259-2b7fc26da123@arm.com> Date: Fri, 5 Oct 2018 17:20:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180924191841.29111-11-babu.moger@amd.com> 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 Babu, On 24/09/18 20:19, Moger, Babu wrote: > Enables QOS feature on AMD. > Following QoS sub-features are supported in AMD if the underlying > hardware supports it. > - L3 Cache allocation enforcement > - L3 Cache occupancy monitoring > - L3 Code-Data Prioritization support > - Memory Bandwidth Enforcement(Allocation) > > There are differences in the way some of the features are implemented. > Separate those functions and add those as vendor specific functions. > The major difference is in MBA feature. > - AMD uses CPUID leaf 0x80000020 to initialize the MBA features. > - AMD uses direct bandwidth value instead of delay based on bandwidth > values. > - MSR register base addresses are different for MBA. > - Also AMD allows non-contiguous L3 cache bit masks. Nice! This is visible to user-space, the 'Cache Bit Masks (CBM)' section of Documentation/x86/intel_rdt_ui.txt currently says 'X86 hardware requires ... a contiguous block'. Does user-space need to know it can do this in advance, or is it a try-it-and-see? Arm's MPAM stuff can do this too, but I'm against having the ABI vary between architectures. If this is going to be discoverable, I'd like it to work on Arm too. Thanks, James > Adds following functions to take care of the differences. > rdt_get_mem_config_amd : MBA initialization function > parse_bw_amd : Bandwidth parsing > mba_wrmsr_amd: Writes bandwidth value > cbm_validate_amd : L3 cache bitmask validation > diff --git a/arch/x86/kernel/cpu/rdt_ctrlmondata.c b/arch/x86/kernel/cpu/rdt_ctrlmondata.c > index 5a282b6c4bd7..1e4631f88696 100644 > --- a/arch/x86/kernel/cpu/rdt_ctrlmondata.c > +++ b/arch/x86/kernel/cpu/rdt_ctrlmondata.c > @@ -123,6 +169,41 @@ bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r) > return true; > } > > +/* > + * Check whether a cache bit mask is valid. AMD allows > + * non-contiguous masks. > + */ > +bool cbm_validate_amd(char *buf, u32 *data, struct rdt_resource *r) > +{ > + unsigned long first_bit, zero_bit, val; > + unsigned int cbm_len = r->cache.cbm_len; > + int ret; > + > + ret = kstrtoul(buf, 16, &val); > + if (ret) { > + rdt_last_cmd_printf("non-hex character in mask %s\n", buf); > + return false; > + } > + > + if (val == 0 || val > r->default_ctrl) { > + rdt_last_cmd_puts("mask out of range\n"); > + return false; > + } > + > + first_bit = find_first_bit(&val, cbm_len); > + zero_bit = find_next_zero_bit(&val, cbm_len, first_bit); > + > + > + if ((zero_bit - first_bit) < r->cache.min_cbm_bits) { > + rdt_last_cmd_printf("Need at least %d bits in mask\n", > + r->cache.min_cbm_bits); > + return false; > + } > + > + *data = val; > + return true; > +} > + > struct rdt_cbm_parse_data { > struct rdtgroup *rdtgrp; > char *buf; >