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 50886C4332F for ; Tue, 22 Nov 2022 02:55:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7F0E6B0071; Mon, 21 Nov 2022 21:55:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A2F298E0001; Mon, 21 Nov 2022 21:55:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91E7A6B0074; Mon, 21 Nov 2022 21:55:17 -0500 (EST) 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 8391C6B0071 for ; Mon, 21 Nov 2022 21:55:17 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 54B8C1A0F40 for ; Tue, 22 Nov 2022 02:55:17 +0000 (UTC) X-FDA: 80159561874.02.7D67DD3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id D76C718000C for ; Tue, 22 Nov 2022 02:55:16 +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 052A661543 for ; Tue, 22 Nov 2022 02:55:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64BC8C43146 for ; Tue, 22 Nov 2022 02:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669085715; bh=y87F50pgoXn/vExBQVCL5ei/ZfSRdM8VAn2jZcONyS0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=UCwlBnf5hBHM8hAHvs/UUi8opNokYQFnS/O0IqClDXowoH8br6cGEbz7Ikt+qqdF0 D+Q4pWK+28b0RFE2HJpUB2pPeTdsYAY+HabC95bdKvlWOHSlfVLzjpv53iyrtO45p/ PJ/uEhtm/qxsPPFnpFO5Fo8FwiIyoQc00soN+MFgchwjgDudsIxT3+lK+FjyQ+jMsr CseK9NbogsyGn04zJtqa3HsqAgTfpsh02dZiGMV6WiDyUc/9tVf5R3cMB197oMDu/f g8YnuDAKCvV0EuYvmmNNIcX19LMmWXaDAi1taio3Gs6X51rs4fzEuIcC9ASJ7WTEi5 eSLcZjwSlIu9w== Received: by mail-ej1-f49.google.com with SMTP id vv4so23474215ejc.2 for ; Mon, 21 Nov 2022 18:55:15 -0800 (PST) X-Gm-Message-State: ANoB5pkQOekmpKEm4asepmCOqHz+cO1sggrkgr3mlLIQp7R03DIbGQ0A FSQhlGiSIfddSpRtvmhlNcnRI+JBWt5+JUnuZzs= X-Google-Smtp-Source: AA0mqf4Fr50DSq7OxTYj2C5VwJm+YBbb7DwZ5Pnkup+zdJ0j80WfsM5Be0e3eIx8FA5Ex/xjC0le/sy/ZMo2nc4tEIE= X-Received: by 2002:a17:906:c34f:b0:78e:17ad:ba62 with SMTP id ci15-20020a170906c34f00b0078e17adba62mr17968858ejb.719.1669085713590; Mon, 21 Nov 2022 18:55:13 -0800 (PST) MIME-Version: 1.0 References: <20221117202322.944661-1-song@kernel.org> In-Reply-To: From: Song Liu Date: Mon, 21 Nov 2022 19:55:01 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v4 0/6] execmem_alloc for BPF programs To: Luis Chamberlain , akpm@linux-foundation.org, Linus Torvalds Cc: bpf@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, peterz@infradead.org, hch@lst.de, rick.p.edgecombe@intel.com, rppt@kernel.org, willy@infradead.org, dave@stgolabs.net, a.manzanares@samsung.com Content-Type: text/plain; charset="UTF-8" ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UCwlBnf5; spf=pass (imf16.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=1669085717; a=rsa-sha256; cv=none; b=zohssg156M0KFz2vZ5vLiUfCMSMkzUE0Ddgjw8AElLOGnXl7hvFFYXu8l0O24HWo/YE2lC 2fDEYqjk8Op2ZbAv4yUJ3e1dqjQqXpYpUxLxOdTRRiMRLPyh1Y+6qd29lcC1zBxooB8TiH 5CEJDLK5W0B4GqNMulJWArAHrcaTpxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669085717; 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=qJDc+UIhmR/jxJl4cJzUJjy96KY9gXq5611kNGFjwvM=; b=N4fXV1iqZKFniyRpNroheCg9LNzCBKFr1BuzD+XccmkfIrkRqrkeVjSrXM1q9kxzdK7aP7 977aMBNqYqQn8js7wLNeTsxeYjWkh9Yf469KSuUGC9XwXZZV8vMOda6mWd82kDqHI8zvUN v0atWsuRLXgBVAqj1JhEo2UsZOSqKJ4= X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UCwlBnf5; spf=pass (imf16.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-Stat-Signature: f8gj3utx7j1kkqie9tsgqos3npgm8wuf X-Rspamd-Queue-Id: D76C718000C X-Rspamd-Server: rspam09 X-HE-Tag: 1669085716-894444 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 Mon, Nov 21, 2022 at 1:12 PM Luis Chamberlain wrote: > > On Thu, Nov 17, 2022 at 12:23:16PM -0800, Song Liu wrote: [...] > > 5. Introduce a unified API to allocate memory with special permissions. > > > > This will help get rid of set_vm_flush_reset_perms calls from users of > > vmalloc, module_alloc, etc. > > And *this* is one of the reasons I'm so eager to see a proper solution > drawn up. This would be a huge win for modules, however since some of > the complexities in special permissions with modules lies in all the > cross architecture hanky panky, I'd prefer to see this through merged > *iff* we have modules converted as well as it would give us a clearer > picture if the solution covers the bases. And we'd get proper testing > on this. Rather than it being a special thing for BPF. Module code is clearly the most difficult to migrate. (It has to work on almost all archs, and it contains 3 allocations: core, data, init.) If we want actionable path towards fixing all these, I don't think we should use module code as the bar for the very first set. (Of course, if Andrew or Linus insists that way, I will rethink about this). PS: I don't quite understand why there is a strong concern in adding this to core mm API, especially that there is also an argument that this is only for BPF. IIUC, the real concern comes for a core API that is 1. easy to use, and have many users; 2. has a horrible internal implementation (maybe bpf_prog_pack falls in here, but it is not easy to use). Such API will cause a lot of problems, and it is also so hard to remove. execmem_* APIs are quite the opposite. It is hard to use, and it has a decent internal implementation (at least better than bpf_prog_pack). In 4/5 of the set, we easily reverted all the code bpf_prog_pack and used execmem_* instead. If execmem_* turn out to be horrible, and only useful for BPF, we can easily migrate it to the next good API, right? Thanks, Song