Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp996070pxa; Fri, 28 Aug 2020 00:12:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4pL3US2c2DhZAtsavUrlO/GRh5MUXqraOAZ4vrlS7cxn2nTwcVndvZYVaIFQ3D0axRjkk X-Received: by 2002:a17:906:4d4d:: with SMTP id b13mr371580ejv.221.1598598726199; Fri, 28 Aug 2020 00:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598598726; cv=none; d=google.com; s=arc-20160816; b=bdc1v6MK5NzsVEcLtm73QKTQJgdRkxqN8ghQ4XeKdqqo9gDwhTNMQm7In1lIwgX/SZ UT2RWdChUFOP4fXRvzQYwRUe2pLf6Ovpbsr/GuT1fyJjOAofvXWiAwadUH2/KOz+BnZR Ayr7ABRd4Aeh+2p7DVSut70u39mXuLwD83A9H/51Ali69a4z9HKfBxRypkfNdJrPzd2j H5/8qO4oNqkcuHOdKuvwGYyFqaaViELuzqmDc3CwoEE4+0ibVj3tqtFbtri9ZKoqOYmV Z9urXJzgKjmv44CLL3eiBqm87LUT+/s2SjT2ER2EzczceJu+iHmEc65YqfW1nUkM6RhU 5aJg== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=00tHBY+tCae86zJA9u8natH/+4zIXXYCZ45d5NLgLfg=; b=cYqUKGqaqWoU01RpEXaTmhUuUv+4a0OQHMZTrV1q8z2ZRqcpU1rtFHEP95dUYDR1os UGlO5sc6TZ9BpeUToiM936mcv5rJ7enpfJB3gI9BBfjPb3gQn+pFcoUgn2taBAcfduwE A9VfGGIMLoy+TToBRKeyOX1JD7+F08SigZbeOqIlrMabyHfPBV6YFddCTobNsPBBpT3Q 43s+bOBXoVbBopWP4RtKIpmFJeQ+UuJB9/JFxccRRRlJZcQB9pm/llGPzqvK/Z2X/WGv peTwU5rJnK+8XJb9rkWsSnm0clkECS0J7thLHityFr6uNT1xYoxniXDpxzhuYTtTSJhE wAqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=GkihBHMi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yl15si91660ejb.301.2020.08.28.00.11.43; Fri, 28 Aug 2020 00:12:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=GkihBHMi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728445AbgH1HJM (ORCPT + 99 others); Fri, 28 Aug 2020 03:09:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbgH1HJL (ORCPT ); Fri, 28 Aug 2020 03:09:11 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88FB4C061264 for ; Fri, 28 Aug 2020 00:09:11 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id z15so52094plo.7 for ; Fri, 28 Aug 2020 00:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=00tHBY+tCae86zJA9u8natH/+4zIXXYCZ45d5NLgLfg=; b=GkihBHMiec5eMP8OBax8z+XGlIotQbtSLdAk9+CKKrSigh++uPLy3NE9fIHGHajhKs hepKEyC3Fdjd+VsvrGyFoSGKa8gNH4CPiTt7s9mgbEtuLz9UWo3CuHdcxNFiiksdzGQz MIVSm7hpK0Upa1rStmgqygQkNzx6CQay1LhTHHz1l2vMYdM06/OyRIKMZG1nlxop1yLt 3oIEKzgv9Ha/3/AdGRdr2IEUTYUNkvmDJwOe48gTld/aPyaBcJHwNKUK5XdOxarYXqaf AUerArzoGkJTP9A2AVjhYhZDudLr5EEiiWTrEUsC5GWCEN/wAVVY1Skodx/YMh2hY5fQ 56LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=00tHBY+tCae86zJA9u8natH/+4zIXXYCZ45d5NLgLfg=; b=SjV/IqFWqIcj36PsGycxi3x2QMzNj1l9XQDqpu1FQdNyylHJyiwLwC7nog5hBs+/N+ l+zQSSFzbxj4xWQcB5vK/ZxOiaPdTVmbYF82FSpR4nE0YQOTFTsVLW7zEFamT5pV3A+o vBQQjddoBkf53x8VByCfUjcc4wvWd+aGsfrTjD/ZTN94KjmuUVb5GUMBqWtqNK6FWHZr Q3OqDh15NQ01uZtciO61tnGEySpVJNQdvrYg9vh/0t8aJu6tA/QIVXZcIOgbDhuhzY+B xozNT9Rk5MD5AD0DcvRlOEdWNgj5JToxDlAbR9a4zyi/KxGbSNlh1B6CqWAatK+KOiZk UoiA== X-Gm-Message-State: AOAM533DiSSjNjjaMGZ0KI9m8+Cqn32qAre9UBwL/BshfOgWE85yRxyd OdxWVPa1GrmueMTSFghf1ZwSSkJl2NF9Bg== X-Received: by 2002:a17:902:7e4b:: with SMTP id a11mr228346pln.325.1598598551032; Fri, 28 Aug 2020 00:09:11 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id b8sm434158pfp.48.2020.08.28.00.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 00:09:10 -0700 (PDT) From: Zong Li To: palmer@dabbelt.com, paul.walmsley@sifive.com, david.abdurachmanov@sifive.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Zong Li Subject: [PATCH v3 0/3] Get cache information from userland Date: Fri, 28 Aug 2020 15:09:04 +0800 Message-Id: X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are no standard CSR registers to provide cache information, the way for RISC-V is to get this information from DT. Currently, AT_L1I_X, AT_L1D_X and AT_L2_X are present in glibc header, and sysconf syscall could use them to get information of cache through AUX vector. We exploit 'struct cacheinfo' to obtain the information of cache, then we don't need additional variable or data structure to record it. We also need some works in glibc, but we have to support the function in kernel first by rule of glibc, then post the patch to glibc site. The result of 'getconf -a' as follows: LEVEL1_ICACHE_SIZE 32768 LEVEL1_ICACHE_ASSOC 8 LEVEL1_ICACHE_LINESIZE 64 LEVEL1_DCACHE_SIZE 32768 LEVEL1_DCACHE_ASSOC 8 LEVEL1_DCACHE_LINESIZE 64 LEVEL2_CACHE_SIZE 2097152 LEVEL2_CACHE_ASSOC 32 LEVEL2_CACHE_LINESIZE 64 Changed in v3: - Fix sparse warning: Use NULL instead of integer 0 Changed in v2: - Add error checking for parsing cache properties. Zong Li (3): riscv: Set more data to cacheinfo riscv: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO riscv: Add cache information in AUX vector arch/riscv/include/asm/cacheinfo.h | 5 ++ arch/riscv/include/asm/elf.h | 13 ++++ arch/riscv/include/uapi/asm/auxvec.h | 24 ++++++++ arch/riscv/kernel/cacheinfo.c | 91 +++++++++++++++++++++++----- 4 files changed, 117 insertions(+), 16 deletions(-) -- 2.28.0