From patchwork Mon May 1 21:05:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13228344 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 4A4A6C7EE24 for ; Mon, 1 May 2023 21:03:00 +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:To:MIME-Version:Message-Id:Date:Subject :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=pw3VvzeblZT1Upe2uBy6It7Px0Bj71Sd94Y/AnlLFEY=; b=BeTz/TbPb+tixA jMDkFM9Xd2ft+9YwswD3NFeFD568njWT4u7mKECR/+hG9feT5iBXRgU/oFsw0hW4ds+kpr/uvF/m1 OkVPt4qGzEGZ0i/XQEHcqwmdzZdFjm9FGvvkuVlvdCD1Z87JMecOjVv8PS/3PCoWPZ7LezzFCEINk z3MuSn+3bO8r0MhxadaZVeGYtOES4vPB5pqpX2LyZfxQrUehaxxAGWUdlkTOYUOs+6h93OoXABYWw rO3CmzqdHAaAvC3O37K+P5dQhFcjrDYH5tW8G8htc4quY3tEmQVYbGNuxTQchm7tOaIDvJgb3Hb8g uI2+BuyJ1Wer2FbK2NOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ptafd-00Gy8k-2a; Mon, 01 May 2023 21:02:53 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ptafZ-00Gy6w-1P for linux-riscv@lists.infradead.org; Mon, 01 May 2023 21:02:52 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-63b4bf2d74aso2087968b3a.2 for ; Mon, 01 May 2023 14:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1682974966; x=1685566966; h=to:content-transfer-encoding:mime-version:message-id:date:subject :from:from:to:cc:subject:date:message-id:reply-to; bh=u+f9STYpQ3MiLUuobcxB6NiQeu6oLquBuiEqTgiW7nU=; b=lBy1tIKVEJ2LC26woBFWq3aTbWu9kIByjssXjub4uONA5jL6a1YtTrEE7NjSLAMyWX MWamHpoRE3PUugO94uw7+1taB6gcVdcMcsQF/OHsuVU++5D7D/K+LrQeC0yXlNC38Kwr n0qRMYU9ccB4TSr3C+23XpODCmc3FSBgoXmiv+cDx6XG1CX1xqIZAuxHyWsVzGz4Jj84 CMxaxxXWanxT+4Hs5UbwRF3TWfVKXCOVELJHMQFEogn4RuWLal8y/6UsS7sFrzyaW5jz djmjyfP09RL71AwOkUp3xQaAe92cuAnctDgB2F9/QIGcHy9CTQ1syZjVMCgtyqvkIPi0 5xlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682974966; x=1685566966; h=to:content-transfer-encoding:mime-version:message-id:date:subject :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u+f9STYpQ3MiLUuobcxB6NiQeu6oLquBuiEqTgiW7nU=; b=aRthPmp4PWE52X5Q4ATtWiOTaAVnOFkK+GKkvktHaH2uyFmSM8pHg5OYZSM4ZUL1F1 2R55q5F+ThBZz/NcQxotO7JoD57HAdTAEYJ/spWrpuZEtNFCp5hqY2K9wKnuhP9wCcT9 gD++1h4hIG2TdHZ2ECbdWEDalzs2/Cnatvf9IWgQORzxpjTaKw7qjZYh922LApF5GY0L Q1DTrWzOmOHzhxF8nJIHY+NZua+xxDT6rgZWyi6mybmDz+S4NJDFGKtkcE1BljOHQ6L/ igiBLeVg+qFLoaTtJp3JeQjbvMnSzu4lvoPbsCC1Di4UyHkX0a239zPq9xWRVi56gOmF gBWA== X-Gm-Message-State: AC+VfDx9xU+ZaAs5VDRfyj9fJ4sdMEKLzvR2smOKOCNqT0PilgCtBUW5 dFDMNW3s7gyy8ZHEuWlMz7wXiA== X-Google-Smtp-Source: ACHHUZ59aSXoviFEB4FBnsHZun5uq6o104ZpmpZfLLV1mJcHU3VtnRTP2MBcZKMAvXC6UNuXFZGI0Q== X-Received: by 2002:a05:6a00:1ac9:b0:641:558:8e2e with SMTP id f9-20020a056a001ac900b0064105588e2emr20397668pfv.15.1682974965937; Mon, 01 May 2023 14:02:45 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1800:f680:1f1:1360:eb9b:387]) by smtp.gmail.com with ESMTPSA id i12-20020a056a00224c00b0063d670ad850sm20899151pfu.92.2023.05.01.14.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 14:02:45 -0700 (PDT) From: Drew Fustini Subject: [PATCH RFC v2 0/2] RISC-V: Detect Ssqosid extension and handle sqoscfg CSR Date: Mon, 01 May 2023 14:05:20 -0700 Message-Id: <20230430-riscv-cbqri-rfc-v2-v2-0-8e3725c4a473@baylibre.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAJApUGQC/2XNQQrCQAyF4auUrA3EaUXqVvAAbsXFTJqx2Yyaw CCU3t2pW5c/vI+3gIupOJy6BUyquj5Li7DrgOdYHoI6tYZAoaehJzR1rsjpbYqWGWvARHTMPO3 HwzBCgym6YLJYeN7ov9hGL5Osn9/zDa6XM9zX9QvLganljgAAAA== To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , Atish Patra , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , James Morse , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Drew Fustini X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1682975186; l=3338; i=dfustini@baylibre.com; s=20230430; h=from:subject:message-id; bh=WhoQqsgjJdsQj4ZRrkR5sEIpHcYxbO2QvzNxfqfpBDE=; b=V29DkhiYqj3tZMXMXV+LYuslsnRGNqE3QVtYjOow8qhlZo6SXlDkOy59pN1/OFwDeCnBwQJVC 2aY2/Vwj6TzB6yADUhDwOdvof3XwUuQMEcIWhSQ7t/Dg++RQlhct9Fq X-Developer-Key: i=dfustini@baylibre.com; a=ed25519; pk=p3GKE9XFmjhwAayAHG4U108yag7V8xQVd4zJLdW0g7g= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230501_140249_664938_9E0CCD8F X-CRM114-Status: GOOD ( 14.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 sqoscfg for the current process. This allows __switch_to_sqoscfg() to be tested without resctrl. This series is based on riscv/for-next at: b09313dd2e72 ("RISC-V: hwprobe: Explicity check for -1 in vdso init") Changes from v1: - change DEFINE_PER_CPU to DECLARE_PER_CPU for cpu_sqoscfg in qos.h to prevent linking error about multiple definition. Move DEFINE_PER_CPU for cpu_sqoscfg into qos.c - renamed qos prefix in function names to sqoscfg to be less generic - handle sqoscfg the same way has_vector and has_fpu are handled in the vector patch series [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-cbqri/message/38 [4] https://gitlab.baylibre.com/baylibre/qemu/-/tree/riscv-cbqri-rfc-v2 [5] https://gitlab.baylibre.com/baylibre/linux/-/tree/riscv-sqoscfg-rfc-v2 [6] https://lore.kernel.org/linux-riscv/20230414155843.12963-1-andy.chiu@sifive.com/ --- 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 | 43 ++++++++++++++++++++++++++++++++++++++ arch/riscv/include/asm/switch_to.h | 3 +++ arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/cpu.c | 1 + arch/riscv/kernel/cpufeature.c | 1 + arch/riscv/kernel/qos/Makefile | 2 ++ arch/riscv/kernel/qos/qos.c | 5 +++++ 11 files changed, 88 insertions(+) --- base-commit: b09313dd2e726fe5e1fa574cd73f5e326c6030a4 change-id: 20230430-riscv-cbqri-rfc-v2-b007fcd19549 Best regards,