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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22047C433FE for ; Thu, 3 Nov 2022 21:14:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B3866B0072; Thu, 3 Nov 2022 17:14:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8623E6B0073; Thu, 3 Nov 2022 17:14:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 729E26B0074; Thu, 3 Nov 2022 17:14:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5FB296B0072 for ; Thu, 3 Nov 2022 17:14:12 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1FFC5C1491 for ; Thu, 3 Nov 2022 21:14:12 +0000 (UTC) X-FDA: 80093383944.15.8EEC1E3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id E574D40002 for ; Thu, 3 Nov 2022 21:14:09 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6EA9662015 for ; Thu, 3 Nov 2022 21:14:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2CEAC433D6 for ; Thu, 3 Nov 2022 21:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667510047; bh=h9p794TMeyeY42pyHV5I4uNCv+zJGK8jrdRhCTMQMmo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=r0biYds1D2pMU7sWY1aXIwcqRdKsZeIXajJQVj91NgEln8pZdZn8EmkOlaHMPOGnZ Y4QhimekaNIBrm85n6vTurhe5tUZx7OoJKt36clrYKjBxI45MQfyfGFK0r1dT4ESTR gVDii7Yq7PfTU3LSf64QP8ZwNlM/tg8ubvWD2U/JpbfLuczVXWRl+EoiVi/6qwTt0A hZtEVgh/56fdBzv8FUTLyPNXlcUMjvsSZXm2jTsds9UpAuYd6sx3FbFWadfHY1T7XI W83FVml+FMC9QPBFfjHVLjxTGKSqVCk3xEjG91wMWQv8dpUjA2j4Q4OCOyo54UmF3Y QOt1EegR8qVYQ== Received: by mail-ej1-f51.google.com with SMTP id bj12so8573075ejb.13 for ; Thu, 03 Nov 2022 14:14:07 -0700 (PDT) X-Gm-Message-State: ACrzQf0f4oDjvtgz7aPDphaI7OvppP4uL8vrWuiwLMzR+ZD9OfW9noGa BRhI6RO6rkPjNa1OSnvRtNwGkxhuhkoS5vAIOGw= X-Google-Smtp-Source: AMsMyM5FJMrio3LZXgI/Wj7a52zZr5jFZCFaYP2IQehQpidns2jdpGn0RkchlqOfjU2x5FCORDDZOirmjofkCwFo+4g= X-Received: by 2002:a17:907:b602:b0:7ad:e82c:3355 with SMTP id vl2-20020a170907b60200b007ade82c3355mr17780468ejc.3.1667510046000; Thu, 03 Nov 2022 14:14:06 -0700 (PDT) MIME-Version: 1.0 References: <20221031222541.1773452-1-song@kernel.org> <14dfef4f077b3c9ebce2526ba2cfebd2c151a036.camel@intel.com> In-Reply-To: <14dfef4f077b3c9ebce2526ba2cfebd2c151a036.camel@intel.com> From: Song Liu Date: Thu, 3 Nov 2022 14:13:53 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v1 RESEND 0/5] vmalloc_exec for modules and BPF programs To: "Edgecombe, Rick P" Cc: "linux-mm@kvack.org" , "bpf@vger.kernel.org" , "hch@lst.de" , "mcgrof@kernel.org" , "peterz@infradead.org" , "akpm@linux-foundation.org" , "x86@kernel.org" , "Hansen, Dave" Content-Type: text/plain; charset="UTF-8" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667510050; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=C9ila/pfk7Sevm8ASWcN1u4sujGwTyqEqBpKYhb3OTQ=; b=EL6ZW8DNxkwapqqDNB4zHwVurZLHG08UWLDJHihhOVeCJvE5c5Lpue6RAbT01F3jke3k9N GMhFlq5ZP0tJQhD7CUa7ZlHtUbXcNftGN//31chmWqegPWQ0cUzEARO9tpvpSSr5kMcsI+ ZfNNkSyJ8TOIV01y4LXlyNYpHqFflxk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=r0biYds1; spf=pass (imf01.hostedemail.com: domain of song@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=song@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667510050; a=rsa-sha256; cv=none; b=3BmPjN70EvjL6f8grC5mZaWIF1dloCicjqUDCwdyDlb8+tOS0aJ+jvEQtbetbxbf78Q+7e J1c90ZrdoksEVYDheiVobI7RWfq0Pu7BWoGLa1Z/QpfIkQZ3DgcUxeAm9CI9Em6A0IHk9m hG6etPP3jxGbKyGs96Hz7mGFP9qaQ+s= X-Stat-Signature: c9aj45nanks8acqkfwyg56hz739ymmi3 X-Rspamd-Queue-Id: E574D40002 X-Rspamd-Server: rspam06 X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=r0biYds1; spf=pass (imf01.hostedemail.com: domain of song@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=song@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1667510049-664932 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, Nov 2, 2022 at 3:30 PM Edgecombe, Rick P wrote: > > On Mon, 2022-10-31 at 15:25 -0700, Song Liu wrote: > > This set enables bpf programs and bpf dispatchers to share huge pages > > with > > new API: > > vmalloc_exec() > > vfree_exec() > > vcopy_exec() > > > > The idea is similar to Peter's suggestion in [1]. > > > > vmalloc_exec() manages a set of PMD_SIZE RO+X memory, and allocates > > these > > memory to its users. vfree_exec() is used to free memory allocated by > > vmalloc_exec(). vcopy_exec() is used to update memory allocated by > > vmalloc_exec(). > > > > Memory allocated by vmalloc_exec() is RO+X, so this doesnot violate > > W^X. > > The caller has to update the content with text_poke like mechanism. > > Specifically, vcopy_exec() is provided to update memory allocated by > > vmalloc_exec(). vcopy_exec() also makes sure the update stays in the > > boundary of one chunk allocated by vmalloc_exec(). Please refer to > > patch > > 1/5 for more details of > > > > Patch 3/5 uses these new APIs in bpf program and bpf dispatcher. > > > > Patch 4/5 and 5/5 allows static kernel text (_stext to _etext) to > > share > > PMD_SIZE pages with dynamic kernel text on x86_64. This is achieved > > by > > allocating PMD_SIZE pages to roundup(_etext, PMD_SIZE), and then use > > _etext to roundup(_etext, PMD_SIZE) for dynamic kernel text. > > It might help to spell out what the benefits of this are. My > understanding is that (to my surprise) we actually haven't seen a > performance improvement with using 2MB pages for JITs. The main > performance benefit you saw on your previous version was from reduced > fragmentation of the direct map IIUC. This was from the effect of > reusing the same pages for JITs so that new ones don't need to be > broken. > > The other benefit of this thing is reduced shootdowns. It can load a > JIT with about only a local TLB flush on average, which should help > really high cpu systems some unknown amount. Thanks for pointing out the missing information. I don't have a benchmark that uses very big BPF programs, so the results I have don't show much benefit from fewer iTLB misses. Song