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 96E8BC433FE for ; Wed, 16 Nov 2022 22:04:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 257236B0075; Wed, 16 Nov 2022 17:04:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 207968E0002; Wed, 16 Nov 2022 17:04:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CF3C8E0001; Wed, 16 Nov 2022 17:04:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id F09FB6B0075 for ; Wed, 16 Nov 2022 17:04:05 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 907A140652 for ; Wed, 16 Nov 2022 22:04:05 +0000 (UTC) X-FDA: 80140684050.22.BFE41CC Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf19.hostedemail.com (Postfix) with ESMTP id 5D9641A000B for ; Wed, 16 Nov 2022 22:04:03 +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 ams.source.kernel.org (Postfix) with ESMTPS id C33BFB81D80 for ; Wed, 16 Nov 2022 22:04:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78C55C43470 for ; Wed, 16 Nov 2022 22:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668636240; bh=bwpmxQtSrtsqOyNAPxt9ZlaY6Emk95Zlx+kQIcsOSAA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=e1NmVpp7FuKV5DsiIzj/9xGdNrLWtZLXaPNDRftQuojcm/WQzV2U16HsgKLY1s0rT NsMUdeNQkNQplFSdW137vywhwbegW5TX3es9TZ23egE5x6mevCaxfF+Yf6ei48Y8SI I40zVEZJW0S8j5PoiD+Leqqn9UDyb1DrKJIXytCYpPG3nqhTbqe1l1VVUG1Ko+wfX5 PBLTy3qLZu7FAVWl9IDGaMrk7YEH8u1L2TI6FwSaY6exAhTuDxYMMEFl3Q+BDKAzyv 0+0AkEFCDnkiCeJvbDXa3NoUV/maB+zeslDN8mq5jdfQmQ/RDhm4llusAhan0UI6Ac uLWruwAeI5rxA== Received: by mail-ed1-f42.google.com with SMTP id e13so19832809edj.7 for ; Wed, 16 Nov 2022 14:04:00 -0800 (PST) X-Gm-Message-State: ANoB5pnULtUU8Ik6IHgeFdo3+Dh9HiPCpFVXXUcT9A8qYXIZkUH9KUiZ ThHypQCiHDjDZi8YATeMVTM0yogUOiVZoF22kGs= X-Google-Smtp-Source: AA0mqf7P4Ff+/DhonOZSGTiSY7bUxCW4GolO70BxnS/8sxv6/4l1Nv+QPD+JZD28zcvmQcigaYEG6UGNFJcNCTZbAf0= X-Received: by 2002:aa7:c6d9:0:b0:462:2c1c:8791 with SMTP id b25-20020aa7c6d9000000b004622c1c8791mr21150173eds.29.1668636238649; Wed, 16 Nov 2022 14:03:58 -0800 (PST) MIME-Version: 1.0 References: <20221107223921.3451913-1-song@kernel.org> <4bf1a1377ea39f287a4fd438d81f314d261f7d7f.camel@intel.com> In-Reply-To: From: Song Liu Date: Wed, 16 Nov 2022 14:03:46 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v2 0/5] execmem_alloc for BPF programs To: "Edgecombe, Rick P" Cc: "peterz@infradead.org" , "rppt@kernel.org" , "bpf@vger.kernel.org" , "linux-mm@kvack.org" , "hch@lst.de" , "x86@kernel.org" , "akpm@linux-foundation.org" , "mcgrof@kernel.org" , "Lu, Aaron" Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668636243; a=rsa-sha256; cv=none; b=ccOqAZEDbu7WbMt28avBiuhDrL5+ZP+pNcn0VPyFYDUZU80Iy/uUo3SBmp1L3NrZaMDGVO giRdOw2IABjt2jvnGU8+UDeg67BX952k92fRPV3u+D6TvF9teK48HpP1BJMGBNzyQ14wuh bfB4Js1i746l0tfxWXpAhtFfMn4hJ6w= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=e1NmVpp7; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of song@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=song@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668636243; 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=5D5TgoJyrV8nwIVN99JCPsKIrNhHyKRgJGBtRUMlviw=; b=5qZQGOPKLDuIQWMoPIKzZrckhjVd2ZFELFimDNtL4VGFZWxG3q//UQ34yFTxTfRBstyKJg ISVrfuCNfa3WnFdfwlOiR6bxLJiElxjHGE2VQTv50v39hPejIlobFns+ni/Y4e0sByTekp w9DFksfJOb8tnIdrxEw3e9PrY5S7Ki4= X-Stat-Signature: yjxcwzp7tf6kbsieed7qg1nu67m1qfms X-Rspamd-Queue-Id: 5D9641A000B X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=e1NmVpp7; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of song@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=song@kernel.org X-Rspamd-Server: rspam09 X-HE-Tag: 1668636243-656253 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Nov 16, 2022 at 1:22 PM Edgecombe, Rick P wrote: > > On Tue, 2022-11-15 at 17:20 -0800, Song Liu wrote: > > To clarify, are you suggesting we need this logic in this set? I > > would > > rather wait until we handle module code. This is because BPF JIT uses > > module_alloc() for archs other than x86_64. So the fall back of > > execmem_alloc() for these archs would be module_alloc() or > > something similar. I think it is really weird to do something like > > > > void *execmem_alloc(size_t size) > > { > > #ifdef CONFIG_SUPPORT_EXECMEM_ALLOC > > ... > > #else > > return module_alloc(size); > > #endif > > } > > > > WDYT? > > Hmm, that is a good point. It looks like it's plugged in backwards. > > Several people in the past have expressed that all the text users > calling into *module*_alloc() also is a little wrong. So I think in > some finished future, each architecture would have an execmem_alloc() > arch breakout of some sort that modules could use instead of it's > module_alloc() logic. So basically all the module_alloc() arch > specifics details of location and PAGE_FOO would move to execmem. > > I guess the question is how to get there. Calling into module_alloc() > does the job but looks wrong. There are a lot of module_alloc()s, but > what about implementing an execmem_alloc() for each bpf jit > architecture that doesn't match the existing default version. It > shouldn't be too much code. I think some of them will work with just > the EXEC_MEM_START/END heuristic and wont need a breakout. > > But if this thing just works for x86 BPF JITs, I'm not sure we can say > we have unified anything... powerpc BPF JIT is getting bpf_prog_pack soon. [1] And we should be able to make ftrace and BPF trampoline to use execmem_alloc soon after this set is merged. AFAICT, we don't have to finalize the API until we handle module text. I personally think current API is good enough for ftrace and BPF trampoline, which already use something similar to JIT. Thanks, Song [1] https://lore.kernel.org/bpf/20221110184303.393179-1-hbathini@linux.ibm.com/