Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp232171pxk; Sun, 30 Aug 2020 00:57:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYutErJE+U91doXI0VADU9f8L6UD/NqXt3gq9O0IcW7R5XhfhFOk7A5Ea4RUp0rR2FGfc+ X-Received: by 2002:a17:906:a206:: with SMTP id r6mr6578562ejy.70.1598774255942; Sun, 30 Aug 2020 00:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598774255; cv=none; d=google.com; s=arc-20160816; b=LoNpusyo9sU7mSnYnlnk41NX76bWEJzm05NVkxPTfiwQtFY6E/76PDi/fUh4YxP2Ff 0Yx7ibdsETjohtYq8bINTs/rDV3Y6TRMoUqBAPzot47WZfgMq2qyWZnV8Nd5rSurpkrG +h/cQU/+CG4SAxE332aSPmj7zFWe0mIxwRIlczjansGq9ix33P/bqyjhZrVlsH9Bkd6s 24FXilyTaMCFWKAOo8Ql29e4PeTyYrJvKkrjJ1OHzk+0r4BdZ45QGOCgFLcmTfGwjlaR OJsJ3kq7Id9cPgW9GQpAJLVnvW7rn35gcrY6GmoMAyiymMa8/vJUrFbIpHakNZjgv8nH t9Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ohDVHll9uNXquWg/6LUDMQsitXnSxjQWS4MTv84+k88=; b=LMIM1SVmJPtCUl+knIeaZuiWfP8+fxcIEDKWyZnfQic1/qcVad49AqC/GgI4p9UNLw qjtcxA5HkDzEzb8NlYXaRlXVfR1rT/Aogb1iE5QJ9O+8L380uKfBAnuipd8Rdz3SmDAq K3qwsJ2dMMzynTot8IVWjhEUcwA4X1QiySjbEchtVsAvmx9GaeyGNMAwicZk24UZ+j2m LRB1Egv5emg/2Ir6bqqvETympwh9/Lig/DHydsNk9u1avQibk/6LfQuUHSlVRlOhPLWO 4C3l+cx/cECpYfe4lvgGn43FdFtqYlcZntn2jpFvUOFQrd/Y9Dp6pUPdE0xqELK9gjKY /RaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QBuiYpmu; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a1si2894758edx.320.2020.08.30.00.57.11; Sun, 30 Aug 2020 00:57:35 -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=@gmail.com header.s=20161025 header.b=QBuiYpmu; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726459AbgH3HyH (ORCPT + 99 others); Sun, 30 Aug 2020 03:54:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbgH3HyF (ORCPT ); Sun, 30 Aug 2020 03:54:05 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1378C061573 for ; Sun, 30 Aug 2020 00:54:04 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id h4so2910194ejj.0 for ; Sun, 30 Aug 2020 00:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ohDVHll9uNXquWg/6LUDMQsitXnSxjQWS4MTv84+k88=; b=QBuiYpmuSQYBHZAZ/Jw90PmwEpkYyjbmSDHyKKMSCvR+m5CDksZFiIlevVBV9sWL/4 MP+Zax0lFrV/IHMEUdh4dUAHlzjeDQLkUkR0u8Y6sXFQoIN0VHVZpdYdUheaDZJGlpjm 8sE0aB9CECoGkPE1b9MzbVkl73XJMvYbOt22NsLUUBjIH6kT/BMME1GgzWWMPT04oeiu rhx2ANl/3qjBrRw4uNoq3y99SNpOpEC3qFSnEIqdb+Uagao8KnmQa0BqiJ9SQbRmi1Zf JTNC+24bWm5BM2tzrhdSnVJCVbod5V5faiEJefafnudd/v0OvTrreWIBk/CcEc28UhQG PXOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ohDVHll9uNXquWg/6LUDMQsitXnSxjQWS4MTv84+k88=; b=lA6Wq55YlWJnC0PTS5fanYJHlzChrRglOXR65gfz4ksBzlGQiAiC/TN7/rK4J2hfS1 8IUhyrH64n/tIm2T4OuDiUz4c673xGTOhnoTW1Wy94yASgY90qPnSkjmKM1UuK1Lpb/L qwWRVqMwP1uREpt9Mvllwfu7sW8CA9lvKAmyqnXRahtk5w8xEvOicDp5krFtj9Fu9Jqg yVKpGFjLEN/wDf319k0DnVZ1buQzEQ7L7PqIYzO75HpV3oq/t+4ynRtbfP2jrezlc/Pq FyEM2E9ebhDaiS47rHAUjN0fjYGHQ/Y1ERmRBCFhIg50p5jGBgB6UEbezyLlEHFm885I 8n6w== X-Gm-Message-State: AOAM533XUTC+WfdlaN5B2FNzwQnLrQ3Qd7qyuj9c2JC9z4T+7fa0ij9J ImFQ35+R/IwzsU9VgZi8WGJjJrwEl8Z1o8UBuZClS3iX7EqbsA== X-Received: by 2002:a17:906:bb06:: with SMTP id jz6mr6991256ejb.248.1598774042143; Sun, 30 Aug 2020 00:54:02 -0700 (PDT) MIME-Version: 1.0 References: <3f1f693147f0b62f19f4a44b8e8ef3d5bde23352.1598598459.git.zong.li@sifive.com> In-Reply-To: <3f1f693147f0b62f19f4a44b8e8ef3d5bde23352.1598598459.git.zong.li@sifive.com> From: Pekka Enberg Date: Sun, 30 Aug 2020 10:53:43 +0300 Message-ID: Subject: Re: [PATCH v3 1/3] riscv: Set more data to cacheinfo To: Zong Li Cc: Palmer Dabbelt , Paul Walmsley , david.abdurachmanov@sifive.com, linux-riscv , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Aug 28, 2020 at 10:09 AM Zong Li wrote: > > Set cacheinfo.{size,sets,line_size} for each cache node, then we can > get these information from userland through auxiliary vector. > > Signed-off-by: Zong Li > --- > arch/riscv/kernel/cacheinfo.c | 59 ++++++++++++++++++++++++++--------- > 1 file changed, 44 insertions(+), 15 deletions(-) > > diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c > index bd0f122965c3..8b85abfbd77a 100644 > --- a/arch/riscv/kernel/cacheinfo.c > +++ b/arch/riscv/kernel/cacheinfo.c > @@ -25,12 +25,46 @@ cache_get_priv_group(struct cacheinfo *this_leaf) > return NULL; > } > > -static void ci_leaf_init(struct cacheinfo *this_leaf, > - struct device_node *node, > - enum cache_type type, unsigned int level) > +static void ci_leaf_init(struct cacheinfo *this_leaf, enum cache_type type, > + unsigned int level, unsigned int size, > + unsigned int sets, unsigned int line_size) > { > this_leaf->level = level; > this_leaf->type = type; > + this_leaf->size = size; > + this_leaf->number_of_sets = sets; > + this_leaf->coherency_line_size = line_size; > + > + /* > + * If the cache is fully associative, there is no need to > + * check the other properties. > + */ > + if (!(sets == 1) && (sets > 0 && size > 0 && line_size > 0)) Can you explain what this is attempting to do? AFAICT, the if expression can be reduced to "sets > 1 && size > 0 && size > 0", but what do you mean with the comment about fully associative caches? > + this_leaf->ways_of_associativity = (size / sets) / line_size; > +}