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,URIBL_BLOCKED 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 7455EC433DF for ; Tue, 21 Jul 2020 23:48:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2F37A20720 for ; Tue, 21 Jul 2020 23:48:39 +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="hsWZwjsr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F37A20720 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 AD58A6B0005; Tue, 21 Jul 2020 19:48:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A5EEC6B0006; Tue, 21 Jul 2020 19:48:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 926466B0007; Tue, 21 Jul 2020 19:48:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id 7851D6B0005 for ; Tue, 21 Jul 2020 19:48:38 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 1161E88F7206 for ; Tue, 21 Jul 2020 23:48:38 +0000 (UTC) X-FDA: 77063725116.19.bell64_1d04b8726f31 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 3357719998 for ; Tue, 21 Jul 2020 23:48:14 +0000 (UTC) X-HE-Tag: bell64_1d04b8726f31 X-Filterd-Recvd-Size: 7213 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Tue, 21 Jul 2020 23:48:13 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id mn17so199769pjb.4 for ; Tue, 21 Jul 2020 16:48:13 -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=mDc030Vht0H+5kxn8kLZcM0RglBvmobnh33JIp70Q9A=; b=hsWZwjsrrb6MHnGlDjXciuMZQ0nzpaGX0XqqotTf6FxppNdslwj80bOHq4XiVr8B4N SCpSNd4Uu+fKdrj6GAgEnicqXWWEP9PCWq23ucc9/tt2akFpRFgjuE9SeU+cCHODPhj8 maVEeY1DOS1y5XfHe5sHYmNqjl4RoWUBn7w7lB8TeTWwtt4QeijAeuGNPjcLeBnjV19B SmugmuJ8ByDeMpqvSyeew7HlPpyj9My215QEtBoF9dt3tORKxn+X2oVXdd2uNIyHmd9b VDJVMDJNscIIFoT2kCXV0OaSjuh8jGAbeGFch/4XoFGO9VWRYU5PdpQ3sp+SqpvXySKf YI/A== 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=mDc030Vht0H+5kxn8kLZcM0RglBvmobnh33JIp70Q9A=; b=JRZCsSCQyvfM0GS9nhFvD42aOo6DC19sTRY9z90zWkb+Aou9UAFf2xrgLgIywCd3SL ptAIAntwOmE3/Y78xDmFAlOIGdlXF8fQaS9KTCBlIPfb7Sg/Ja+0p7rqhAdJMBXcDG60 8Rq2RUrIKL9FLTICVMixvnERx5YuwQ67msEFoP/zfbBqzVsfUvMP1HRYD/doqFKtQ5+V W1nlDnTAkNIuQjobiUbAuPhXMbDbITd048phta3Ft6gmJQ2njSQQnMiAkoTh7sJw9KDI uilE0CekSjDn7L9Ih4U1HzwjRvidQH5W9zErTBvKoa19we6LBTAXXVvMdy7MGs7mXWz+ vGJA== X-Gm-Message-State: AOAM530t6VKTuTM9hG5QUw+2IaDfWLKn4HpLkcvflG2B88s0nLj6fH3V zza/pqueeMxvI2xrPGzohwd9Ww== X-Google-Smtp-Source: ABdhPJz7GQOPhPQo7WdQAVqmRGBn/kBHYhew0a/7KykfyZ8e5DBJEpqbOEQfucs+jTILpvC6kcl9RQ== X-Received: by 2002:a17:90a:cc03:: with SMTP id b3mr6637665pju.80.1595375292546; Tue, 21 Jul 2020 16:48:12 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id i66sm20870634pfc.12.2020.07.21.16.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 16:48:11 -0700 (PDT) Date: Tue, 21 Jul 2020 16:48:11 -0700 (PDT) X-Google-Original-Date: Tue, 21 Jul 2020 16:48:10 PDT (-0700) Subject: Re: [PATCH v5 1/4] riscv: Move kernel mapping to vmalloc zone In-Reply-To: <6fbea8347bdb8434d91cf3ec2b95b134bd66cfe3.camel@kernel.crashing.org> CC: alex@ghiti.fr, 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 From: Palmer Dabbelt To: benh@kernel.crashing.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed X-Rspamd-Queue-Id: 3357719998 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 Tue, 21 Jul 2020 16:12:58 PDT (-0700), benh@kernel.crashing.org wrote: > 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 ? Nothing fundamental, it's just that we don't have a large code model in t= he C compiler. As a result all the global symbols are resolved as 32-bit PC-relative accesses. We could fix this with a fast large code model, bu= t then the kernel would need to relax global symbol references in modules and we= don't even do that for the simple code models we have now. FWIW, some of the proposed large code models are essentially just split-PLT/GOT and therefo= r don't require relaxation, but at that point we're essentially PIC until w= e have more that 2GiB of kernel text -- and even then, we keep all the performance issues. >> 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 th= ey'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. Essentially what's above, the modules smell the same as the rest of the kernel's code and therefor have a similar set of restrictions. If we bui= ld PIC modules and have the PLT entries do GOT loads (as do our shared libraries= ) then we could break this restriction, but that comes with some performance implications. Like I said in the other email, I'm less worried about the instruction side of things so maybe that's the right way to go. >> * 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 ? Our PIC codegen, probably better addressed by my other email and above. > >> Roughly, my proposal would be to: >> >> * Leave the 32-bit memory map alone. On 32-bit systems we can load mo= dules >> 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, a= s its own >> region. We'd link/relocate the kernel here instead of around PAGE_O= FFSET, >> which would decouple the kernel from the physical memory layout of t= he 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 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. >> >> This doesn't solve the problem of virtually relocatable kernels, but i= t does >> let us decouple that from the sv48 stuff. It also lets us stop relyin= g on a >> fixed physical address the kernel is loaded into, which is another thi= ng I >> don't like. >> >> I know this may be a more complicated approach, but there aren't any s= v48 >> 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 significa= nt >> performance penalty on all systems).