From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1957DC433E1 for ; Wed, 22 Jul 2020 19:52:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9D74920771 for ; Wed, 22 Jul 2020 19:52:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=dabbelt-com.20150623.gappssmtp.com header.i=@dabbelt-com.20150623.gappssmtp.com header.b="Yoy1F4D5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D74920771 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E427B6B0002; Wed, 22 Jul 2020 15:52:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF3266B0005; Wed, 22 Jul 2020 15:52:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB99C6B0006; Wed, 22 Jul 2020 15:52:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id B5B4A6B0002 for ; Wed, 22 Jul 2020 15:52:42 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 571481828AC66 for ; Wed, 22 Jul 2020 19:52:42 +0000 (UTC) X-FDA: 77066759364.28.sea75_6311ff026f38 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 2FA321072CBD7 for ; Wed, 22 Jul 2020 19:52:42 +0000 (UTC) X-HE-Tag: sea75_6311ff026f38 X-Filterd-Recvd-Size: 6664 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Wed, 22 Jul 2020 19:52:41 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id j19so1844245pgm.11 for ; Wed, 22 Jul 2020 12:52:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=1cGKIJpjawJti4g8SzXEonfEdlP5yq0CvN8z5K3Dldw=; b=Yoy1F4D5SdX59+ds7mcQz5JHUDBl4fr7U9s03rPcO/LhScRFnIG9oYi04943Pyg2ap QO8rRLplFMiQLcJhq6abEof80+wc3Cq6YgtwLMpVrrfBBOLBgDW9EtB8SRwK7b5TouNo FG7RpEdSt3aWO6VpWh5zPY+WHf6SYyc+NMhPEgpsdu+1hdfzb5rqGk7Mk2vGBCpiLMfk M2WMXdpC7+mWmSRDiq6A2yI2qfWzI9/2a5PLaIDTVfkIW+UfI26AMELRrElSVaArF2AH f+NZ0cHy9P0lcCkdQ8Agh4YYefdHQyxAnmIhKl992R0eGV3Njth6PWUOMpPlFy1YKm3v Muug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=1cGKIJpjawJti4g8SzXEonfEdlP5yq0CvN8z5K3Dldw=; b=EMq+dCGAMx9q2zmdZ+kSYTwMIXeCL1VFdXmFC9m7D7AFDM5g0bOXXSkBBalHOewlVr 8lhvApC+5N/165O9VQ7DPR29WyaqfFKQwGRpYxLGZKLnYnR3xTLMn4J36+JYbxWvtwPw Aq9yM2GQqIWxsVbrRo87su3oEQY2t0QWvTDNP3MyozR8i8499zBbgdpHNu+nxlhM9hmO v17KaxaST0JlE5eZvtcXFp7J5o8XE6EtyFkKNpxdZpWjHMsevu9ixrW+Cl0/pF/0Hl0W uScFFWhAbdmyRJaD3zaBFkcF431yUt8BE/TpsOmq7aiDSYcvfyuqA4Z4p28Y2LDeb3V6 WlJQ== X-Gm-Message-State: AOAM530cO2At0FfGMGB6qbQ2qCOrqJQPQXMh/KJQRcQamhOlmfOZPDXo IwbS9o6i0HLKFzIx6o1ezH2Niw== X-Google-Smtp-Source: ABdhPJzfnsEJ9u3sgDkfEADIkHOoeK603qojzxPEwBQeACIUHuB6n2njWNz3cI4X1mmHVknKJAO4xQ== X-Received: by 2002:a63:8c4f:: with SMTP id q15mr1206804pgn.373.1595447560352; Wed, 22 Jul 2020 12:52:40 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id q13sm443560pfk.8.2020.07.22.12.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 12:52:39 -0700 (PDT) Date: Wed, 22 Jul 2020 12:52:39 -0700 (PDT) X-Google-Original-Date: Wed, 22 Jul 2020 12:52:36 PDT (-0700) Subject: Re: [PATCH v5 1/4] riscv: Move kernel mapping to vmalloc zone In-Reply-To: CC: alex@ghiti.fr, aou@eecs.berkeley.edu, benh@kernel.crashing.org, linux-mm@kvack.org, mpe@ellerman.id.au, Anup Patel , linux-kernel@vger.kernel.org, Atish Patra , paulus@samba.org, zong.li@sifive.com, Paul Walmsley , linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org From: Palmer Dabbelt To: Arnd Bergmann Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed X-Rspamd-Queue-Id: 2FA321072CBD7 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 22 Jul 2020 02:43:50 PDT (-0700), Arnd Bergmann wrote: > On Tue, Jul 21, 2020 at 9:06 PM Palmer Dabbelt wro= te: >> >> On Tue, 21 Jul 2020 11:36:10 PDT (-0700), alex@ghiti.fr wrote: >> > Let's try to make progress here: I add linux-mm in CC to get feedbac= k on >> > this patch as it blocks sv48 support too. >> >> Sorry for being slow here. I haven't replied because I hadn't really = fleshed >> out the design yet, but just so everyone's on the same page my problem= s with >> this are: >> >> * We waste vmalloc space on 32-bit systems, where there isn't a lot of= it. > > There is actually an ongoing work to make 32-bit Arm kernels move > vmlinux into the vmalloc space, as part of the move to avoid highmem. > > Overall, a 32-bit system would waste about 0.1% of its virtual address = space > by having the kernel be located in both the linear map and the vmalloc = area. > It's not zero, but not that bad either. With the typical split of 3072 = MB user, > 768MB linear and 256MB vmalloc, it's also around 1.5% of the available > vmalloc area (assuming a 4MB vmlinux in a typical 32-bit kernel), but t= he > boundaries can be changed arbitrarily if needed. OK, I guess maybe it's not so bad. Our 32-bit defconfig is 10MiB, but I wouldn't really put much weight behind that number as it's just a 64-bit defconfig built for 32-bit. We don't have any 32-bit hardware anyway, so= if this becomes an issue later I guess we can just deal with it then. > The eventual goal is to have a split of 3840MB for either user or linea= r map > plus and 256MB for vmalloc, including the kernel. Switching between lin= ear > and user has a noticeable runtime overhead, but it relaxes both the lim= its > for user memory and lowmem, and it provides a somewhat stronger > address space isolation. Ya, I think we decided not to do that, at least for now. I guess the rig= ht answer there will depend on what 32-bit systems look like, and since we d= on't have any I'm inclined to just stick to the fast option. > Another potential idea would be to completely randomize the physical > addresses underneath the kernel by using a random permutation of the > pages in the kernel image. This adds even more overhead (virt_to_phys > may need to call vmalloc_to_page or similar) and may cause problems > with DMA into kernel .data across page boundaries, > >> * Sort out how to maintain a linear map as the canonical hole moves ar= ound >> between the VA widths without adding a bunch of overhead to the virt= 2phys and >> friends. This is probably going to be the trickiest part, but I thi= nk 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. > > I assume you can't use the trick that x86 has where all kernel addresse= s > are at the top of the 64-bit address space and user addresses are at th= e > bottom, regardless of the size of the page tables? They have the load in their mapping functions, as far as I can tell that'= s required to do this sort of thing. We do as well to handle some of the implicit boot stuff for now, but I was assuming that we'd want to get rid= of that for performance reasons. That said, maybe it just doesn't matter? =20