Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1360716pxf; Fri, 12 Mar 2021 07:53:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpHXOIaVPnlyltMT2CE2ZxTTITr014idykfGjd2+fASYuIPGIaXjbz1Sql9uODnqWJCIhL X-Received: by 2002:a17:906:fc1c:: with SMTP id ov28mr9231033ejb.342.1615564433142; Fri, 12 Mar 2021 07:53:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615564433; cv=none; d=google.com; s=arc-20160816; b=hnwzhnn9xhI1Vf+x9buW34aFsvFT9cfBFccDmUoy509Usaq3HCwgx5Wv862hW90v7/ CBbzUJh7ZSMLWl09XEG7TfJgspZuAojmIaN3FjBBQG8ljLiCGKY7ypNdbjvtJvzgLcbU 4PsdH0ZzrCjr6lBbIFF5g99xXrs+W1BwsuC3rN5Q3hO6RBkU47TkljYvW1DEmgHKJOxn pnySnRBOoK39zSMTjB04/eFzlQnx3tXJT/01ws/gSWtQDjqvk2U3kBzhFdIjC/LvhvF0 sLa8xRLNboGOFp+/uCMN6/40r3S5WWcPTH0afJ6dfna2S/mUwMzUkrVZwjb6HtmcOrTe tmTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=+ufGY0BpS1FFe+dVBdNB94a4xu++ZlC5MzGN3kgXpLE=; b=xOxNSuOCMfC/TkcCtiLkxO7wPr/Hp3MgOHbwse1f/Jcr94zHHoPs4gkZMDVBxTa7Vb ESPNiC/N+2Xtp/J0kKaTgYu5mb2qi8Hu5C2H3j4f6NQmWoCvjH6nzCuzEn8ShpIk+XTO lA+bj5BgQ7QSae7wBY2511P6E/36J0gOKlHa/SiRg9feX+kynAa00e8NjCPSAsrrQFi6 8B1sBN1hJIxksv7UJPXnAugrAbKapq5h6ZuNVpseRR76v6cON73fv6pu2yis/oICz2bT iILj0H+33xoaJm2EStMtIbkDkoCHu5eA99XJ2IRU11ZeJ8D2b+Pr3j0ThOPUNuNcb69t XfRw== ARC-Authentication-Results: i=1; mx.google.com; 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 q16si4612492ejt.685.2021.03.12.07.53.30; Fri, 12 Mar 2021 07:53:53 -0800 (PST) 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; 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 S232148AbhCLPwf (ORCPT + 99 others); Fri, 12 Mar 2021 10:52:35 -0500 Received: from mail-ua1-f43.google.com ([209.85.222.43]:44711 "EHLO mail-ua1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231597AbhCLPwN (ORCPT ); Fri, 12 Mar 2021 10:52:13 -0500 Received: by mail-ua1-f43.google.com with SMTP id q18so1460585uas.11 for ; Fri, 12 Mar 2021 07:52:13 -0800 (PST) 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=+ufGY0BpS1FFe+dVBdNB94a4xu++ZlC5MzGN3kgXpLE=; b=UY0+OOFuVkRynifu5L9Oq9abKTcqNpgmRyes4M1izKNyN41yUD5Wdz3glQEzcylTT4 FbBVOFbb9J8dM5jJl0QOq57Fr1xqgk8uUE737aYK8XfyO7S7ifk3CyE/EEtUtsylWRTe 5rJLXcITDhXEzlTYRWfqeM+W+CTsGdLwBW16Fg+8HxPhrdBCsvs+wIyF3U9vUI2F1NvC aET/v17RkrZkaVJs6fzwou4Lz/0NNKYyaoVi9GPpu+ClWb3Yl/SySloBBM2jRareUd/A AkOjQrLbo1o89qp2EDptSOJDYqAMa1nQFMgoufueBueCv6AkhTBcAydBNG56eJhEllgf oc+w== X-Gm-Message-State: AOAM531tlwRk4SVydjs90F3At2fDd19nSkuPZanEB70eEr07wz72qNBC E6vfYcTOaBcKHAyRkiOPe370tnPNckudWDzVUXI= X-Received: by 2002:ab0:30b3:: with SMTP id b19mr8849816uam.58.1615564332725; Fri, 12 Mar 2021 07:52:12 -0800 (PST) MIME-Version: 1.0 References: <20210107092652.3438696-4-atish.patra@wdc.com> In-Reply-To: From: Geert Uytterhoeven Date: Fri, 12 Mar 2021 16:52:01 +0100 Message-ID: Subject: Re: [PATCH 3/4] RISC-V: Fix L1_CACHE_BYTES for RV32 To: Atish Patra Cc: Palmer Dabbelt , Albert Ou , Anup Patel , "linux-kernel@vger.kernel.org List" , Ard Biesheuvel , Atish Patra , Paul Walmsley , Nick Kossifidis , linux-riscv , Andrew Morton , Mike Rapoport Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 14, 2021 at 7:34 PM Atish Patra wrote: > On Wed, Jan 13, 2021 at 9:10 PM Palmer Dabbelt wrote: > > On Thu, 07 Jan 2021 01:26:51 PST (-0800), Atish Patra wrote: > > > SMP_CACHE_BYTES/L1_CACHE_BYTES should be defined as 32 instead of > > > 64 for RV32. Otherwise, there will be hole of 32 bytes with each memblock > > > allocation if it is requested to be aligned with SMP_CACHE_BYTES. > > > > > > Signed-off-by: Atish Patra > > > --- > > > arch/riscv/include/asm/cache.h | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/arch/riscv/include/asm/cache.h b/arch/riscv/include/asm/cache.h > > > index 9b58b104559e..c9c669ea2fe6 100644 > > > --- a/arch/riscv/include/asm/cache.h > > > +++ b/arch/riscv/include/asm/cache.h > > > @@ -7,7 +7,11 @@ > > > #ifndef _ASM_RISCV_CACHE_H > > > #define _ASM_RISCV_CACHE_H > > > > > > +#ifdef CONFIG_64BIT > > > #define L1_CACHE_SHIFT 6 > > > +#else > > > +#define L1_CACHE_SHIFT 5 > > > +#endif > > > > > > #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) > > > > Should we not instead just > > > > #define SMP_CACHE_BYTES L1_CACHE_BYTES > > > > like a handful of architectures do? > > > > The generic code already defines it that way in include/linux/cache.h > > > The cache size is sort of fake here, as we don't have any non-coherent > > mechanisms, but IIRC we wrote somewhere that it's recommended to have 64-byte > > cache lines in RISC-V implementations as software may assume that for > > performance reasons. Not really a strong reason, but I'd prefer to just make > > these match. > > > > If it is documented somewhere in the kernel, we should update that. I > think SMP_CACHE_BYTES being 64 > actually degrades the performance as there will be a fragmented memory > blocks with 32 bit bytes gap wherever > SMP_CACHE_BYTES is used as an alignment requirement. > > In addition to that, Geert Uytterhoeven mentioned some panic on vex32 > without this patch. > I didn't see anything in Qemu though. FTR, I no longer need this patch on vexriscv. It seems it just masked an issue. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds