Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp55915ybh; Tue, 21 Jul 2020 16:16:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjdnNZaFqHX7DEv/6q/OGnulKDi2MyiNDO+XaUG7DAmTBvljyYHXdou1kPllWKBeenHlOT X-Received: by 2002:a05:6402:1597:: with SMTP id c23mr27069989edv.243.1595373375487; Tue, 21 Jul 2020 16:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595373375; cv=none; d=google.com; s=arc-20160816; b=yTBh0X5/udWryz/WKdVrhSsZR4J4/TLPhEr61rmxJpaREXaAhwRHmKD4XofGn9bDOn Rg8PtERmYXrF56VZ11mXLifpaYE0jQkdSkSQl08nfX1R6ZPVK9P0R0ohPV+Hy2Xy4OMo pj3OT+tMun9SWYgpBw4FW3EPdQssGJ6rqYghh1R1DYa1BQOXRjrM+5mYGUyc/8jBXgMB +yXnoWGU5TrDYVxIonfObYXeoyGP/ySQM/0MvMeZfI6FfaAhUR/yxhv74k2xU7pKNV57 PBWyaBVl57PwmZFHlJQYejdV9jL+KCKBcoWLgwubz3LhlCUJscfcAPuQXa7VGW8FMT56 oPWg== 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 :references:in-reply-to:date:cc:to:from:subject:message-id; bh=7M0Ok76JfT+W6G5mwfjU4zbiDsm/zsfVQcp3Ny6XVp8=; b=fCKz+yLSop4iEqZ8xo2owPgdPCkmyyEC+MLBOfB6+LcZ0Kffa+LPwAW7Tau14NgiBj GTwz2GCQHXxzXkTwFkOmLv+HRjHISj75wqP/0NUN1IJt3SPE+xW5o68hqV9zh1XPYLOL 0br+TCdq/kNKVpkA5MG95EdSuhqJkZ+qHl793wTXdKbRA6EgADFU6CX8EOz1fccXjNCL 9P8YZvxRSvH/5/aWmhl9TQNcYcrh8pnSoCh1KALHcKGJx5mB3a9LJ2AYIlzu+f28rmzM YVnOgLCfJmcIDDlANocesGvlzYVuFjCANLVpOG8jHQnRur+px4lFpCUb4Dz7eMQAweho LbVQ== 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 rv20si14135969ejb.420.2020.07.21.16.15.53; Tue, 21 Jul 2020 16:16:15 -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; 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 S1731427AbgGUXNq (ORCPT + 99 others); Tue, 21 Jul 2020 19:13:46 -0400 Received: from kernel.crashing.org ([76.164.61.194]:41692 "EHLO kernel.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbgGUXNp (ORCPT ); Tue, 21 Jul 2020 19:13:45 -0400 Received: from localhost (gate.crashing.org [63.228.1.57]) (authenticated bits=0) by kernel.crashing.org (8.14.7/8.14.7) with ESMTP id 06LNCxrb017185 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 21 Jul 2020 18:13:05 -0500 Message-ID: <6fbea8347bdb8434d91cf3ec2b95b134bd66cfe3.camel@kernel.crashing.org> Subject: Re: [PATCH v5 1/4] riscv: Move kernel mapping to vmalloc zone From: Benjamin Herrenschmidt To: Palmer Dabbelt , alex@ghiti.fr Cc: mpe@ellerman.id.au, paulus@samba.org, Paul Walmsley , aou@eecs.berkeley.edu, Anup Patel , Atish Patra , zong.li@sifive.com, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-mm@kvack.org Date: Wed, 22 Jul 2020 09:12:58 +1000 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-07-21 at 12:05 -0700, Palmer Dabbelt wrote: > > * We waste vmalloc space on 32-bit systems, where there isn't a lot of it. > * On 64-bit systems the VA space around the kernel is precious because it's the > only place we can place text (modules, BPF, whatever). Why ? Branch distance limits ? You can't use trampolines ? > If we start putting > the kernel in the vmalloc space then we either have to pre-allocate a bunch > of space around it (essentially making it a fixed mapping anyway) or it > becomes likely that we won't be able to find space for modules as they're > loaded into running systems. I dislike the kernel being in the vmalloc space (see my other email) but I don't understand the specific issue with modules. > * Relying on a relocatable kernel for sv48 support introduces a fairly large > performance hit. Out of curiosity why would relocatable kernels introduce a significant hit ? Where about do you see the overhead coming from ? > Roughly, my proposal would be to: > > * Leave the 32-bit memory map alone. On 32-bit systems we can load modules > anywhere and we only have one VA width, so we're not really solving any > problems with these changes. > * Staticly allocate a 2GiB portion of the VA space for all our text, as its own > region. We'd link/relocate the kernel here instead of around PAGE_OFFSET, > which would decouple the kernel from the physical memory layout of the system. > This would have the side effect of sorting out a bunch of bootloader headaches > that we currently have. > * Sort out how to maintain a linear map as the canonical hole moves around > between the VA widths without adding a bunch of overhead to the virt2phys and > friends. This is probably going to be the trickiest part, but I think if we > just change the page table code to essentially lie about VAs when an sv39 > system runs an sv48+sv39 kernel we could make it work -- there'd be some > logical complexity involved, but it would remain fast. > > This doesn't solve the problem of virtually relocatable kernels, but it does > let us decouple that from the sv48 stuff. It also lets us stop relying on a > fixed physical address the kernel is loaded into, which is another thing I > don't like. > > I know this may be a more complicated approach, but there aren't any sv48 > systems around right now so I just don't see the rush to support them, > particularly when there's a cost to what already exists (for those who haven't > been watching, so far all the sv48 patch sets have imposed a significant > performance penalty on all systems).