From patchwork Mon Apr 10 04:36:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13206100 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40763C77B6F for ; Mon, 10 Apr 2023 04:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=9trHQCVmyglLagCEWRiYS6faj0pb2w7DB0HHBr7zDaM=; b=aoOJ4r27mZm5MO n08iO6D8LxChPVj13npO6rAsYsDmnlcdoCCew0mIP5rDKtuxkz4Y/CXvmE5Zmx7BtBlwoNA2KyfEG kc1JwWM61vAxCj/uxrEqnZurVBjNGa0tKdNCDGaCSUcCFiIeWBBPUPBVqOYyEg6gmPferOUhQI69I 7Sjk8gfJmToykBFRgznnvpWoIWszNRADdjHGVJvUzTA8AIsPuTIFtRt2Utwk+MOP5vn392A6Sjfr6 HCONMDdhZ/HwsXPGjBZZ0WvpqQcB4+9A/FRDzTFqJq0JLIu4ozLwqWVMBHN76CxxBeqTHcqevKvGc axjQ5+VbdFr6NqVQsoHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pljEb-00EYY0-1l; Mon, 10 Apr 2023 04:34:29 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pljEW-00EYWG-1P for linux-riscv@lists.infradead.org; Mon, 10 Apr 2023 04:34:27 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-635df3bd6e9so1002101b3a.1 for ; Sun, 09 Apr 2023 21:34:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1681101261; x=1683693261; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wo/NLYM68CpVej7TFrEwhf6OkmmykabPIEmuzOcGQhk=; b=14ynvSGMjNFozUEgNPf5yBPQdprMlno4GnJrckN9NKprlViZIhNxxhN+f827VAuy1q xTJdqsEWvAxss3rv3YkvvUiGOM/KAiDibpbl0fr9nq2K6FGQrFdYZNr79ZVV37OrqjCY yOINUEMPyaQksnmOmcwjlbYCyYPvYji/7ZpU41pQRlDaWVovmxudkH49/g12crFxYvXC OpSK2bG0bF5NUz+BCbClWhGq24I5+PSrqoXIggZa1XWhsu+DqcFrFNuiT2UNJgvqRQZB nTCxHZpXU/Nsj0PFIeThbrBkVXfwGDvE9LqKheqwp4tJvZZZsK+6bqAMhqoBLxJOYZE6 6DSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681101261; x=1683693261; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wo/NLYM68CpVej7TFrEwhf6OkmmykabPIEmuzOcGQhk=; b=Z3lhnDkZE/z5ZZfZvq11m5SPH5RFyRQoG/7F4Ry6RPhDSbdQddx/6E0r0dRxA42yWF iYhIca9b2F2IMfhHcPff56vh1ShbM3993RLo7CJDKL7Vh2y7r6YyBebLfYgDM4oY9lYk 1yI3LKF2ZzFlVPBCsnHr8Of4Jpf1Jivl+/a+NRewWkldAtc4jVg2Wwg+rgB6q+g/BNNG 480HOMNWtVoNClWTJjVbw0GDypUrQlQywXBky3vxoJf3e7P3LKh/R8uJdRMFPI5yyJAn 14O1esHA75KlfHCpgemFKBcmLI0C7BtJtuiipBWnaSAqkQHKVbdqHM4EE6ZUwK44kamM WO4A== X-Gm-Message-State: AAQBX9cF2WQCK1C3zGoXU9dqYq9YwakMrOskL8I0RkscVsUTCXgdleGT TuLV14Lxj3eavr9Cas85aD/j/lrRa/Bk9/OvfZqiPA== X-Google-Smtp-Source: AKy350Z2pVohIIfC8uOSvebyeFmf1J41yDqHZ+iw/kR/cSkcgoer36lMoJOfnE61nWFF+haa+PKKiA== X-Received: by 2002:a62:180b:0:b0:628:1862:dda6 with SMTP id 11-20020a62180b000000b006281862dda6mr9491271pfy.17.1681101261451; Sun, 09 Apr 2023 21:34:21 -0700 (PDT) Received: from x1.. ([2601:1c2:1801:d250:45c0:94f2:eea7:6dc3]) by smtp.gmail.com with ESMTPSA id x24-20020aa793b8000000b00634a96493f7sm2394411pff.128.2023.04.09.21.34.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Apr 2023 21:34:20 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Atish Patra , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , James Morse , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi Cc: Drew Fustini Subject: [RFC PATCH 0/2] RISC-V: Detect Ssqosid extension and handle sqoscfg CSR Date: Sun, 9 Apr 2023 21:36:44 -0700 Message-Id: <20230410043646.3138446-1-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230409_213424_636024_8532E4CD X-CRM114-Status: GOOD ( 15.13 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This RFC series adds initial support for the Ssqosid extension and the sqoscfg CSR as specified in Chapter 2 of the RISC-V Capacity and Bandwidth Controller QoS Register Interface (CBQRI) specification [1]. QoS (Quality of Service) in this context is concerned with shared resources on an SoC such as cache capacity and memory bandwidth. Intel and AMD already have QoS features on x86, and there is an existing user interface in Linux: the resctrl virtual filesystem [2]. The sqoscfg CSR provides a mechanism by which a software workload (e.g. a process or a set of processes) can be associated with a resource control ID (RCID) and a monitoring counter ID (MCID) that accompanies each request made by the hart to shared resources like cache. CBQRI defines operations to configure resource usage limits, in the form of capacity or bandwidth, for an RCID. CBQRI also defines operations to configure counters to track the resource utilization of an MCID. The CBQRI spec is still in draft state and is undergoing review [3]. It is possible there will be changes to the Ssqosid extension and the CBQRI spec. For example, the CSR address for sqoscfg is not yet finalized. My goal for this RFC is to determine if the 2nd patch is an acceptable approach to handling sqoscfg when switching tasks. This RFC was tested against a QEMU branch that implements the Ssqosid extension [4]. A test driver [5] was used to set thread_struct.sqoscfg for the current process. This allowed __qos_sched_in() to be tested without resctrl. A forthcoming RFC series will enable resctrl to support systems that implement CBQRI and will reference a QEMU branch that implements CBQRI. NOTE: CBQRI was previously known as CMQRI and the github repo with the spec has not yet been renamed [6]. [1] https://github.com/riscv-non-isa/riscv-cmqri/blob/main/riscv-cbqri.pdf [2] https://docs.kernel.org/x86/resctrl.html [3] https://lists.riscv.org/g/tech-cmqri/message/38 [4] https://github.com/pdp7/qemu/tree/ssqosid_v8.0.0-rc1 [5] https://github.com/pdp7/linux/commits/ssqosid_sqoscfg_v6.3 [6] https://lists.riscv.org/g/tech-cmqri/message/41 Drew Fustini (1): RISC-V: Add support for sqoscfg CSR Kornel Dulęba (1): RISC-V: Detect the Ssqosid extension arch/riscv/Kconfig | 19 ++++++++++++++ arch/riscv/include/asm/csr.h | 8 ++++++ arch/riscv/include/asm/hwcap.h | 2 ++ arch/riscv/include/asm/processor.h | 3 +++ arch/riscv/include/asm/qos.h | 40 ++++++++++++++++++++++++++++++ arch/riscv/include/asm/switch_to.h | 2 ++ arch/riscv/kernel/cpu.c | 1 + arch/riscv/kernel/cpufeature.c | 1 + 8 files changed, 76 insertions(+) create mode 100644 arch/riscv/include/asm/qos.h base-commit: d34a6b715a23ccd9c9d0bc7a475bea59dc3e28b2