Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5207791pxb; Wed, 26 Jan 2022 07:07:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJysiPIlseTwRHraFRE/6BwFzjOEy/WuuQa1AXH88beUFL6BcXIFrjtZR6AGyf1qoSxGV/V8 X-Received: by 2002:a17:90b:f92:: with SMTP id ft18mr9261449pjb.113.1643209652398; Wed, 26 Jan 2022 07:07:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643209652; cv=none; d=google.com; s=arc-20160816; b=QeLSp4rwUf4H6kYP0EYgHXz7BaXA9fGtmXMYkYk1PjNBbicl+r961MrIlGFOVk4U9p MkY1EAvoj4Ur4EsWqHSxNkKymlKi3rCdJUr5K1rinAOPGY7ltbnGxCRg3/WJyOfzK/sY IYwILzL11yUfq0D3QhXCJLZaXVM37/RC7jTkGcie4QgCNyngEi/LnTiiY9taieivS9f2 /kQAe3/xPRtpil5OKP8WZQFqUjGfgGuMvBVmyLGXobM9623JqMfkA8hha6KQyz+2aZ// yoLIjXsAI0Zca7ak3Nz9gdbtKdCLKOpkubVMYMR7VdanJnWdaZcgRqWVJexvM629Nx0Q p1jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Cvu0VgXWiQ6M2Gi0kUJ3rf5j0Wkl52nTsVNfKcKMFI0=; b=Y9q9e3+aZYX8KUDWtdyCoBJWRMq3JeT6m08fbux5BblFUw9EKrP9In1rodcPnxPkhX P//1X2uJWIqHFZ88P9nyC+rcyVHWw6k5yFLE44L3xcx3Mr9+kCni5QVsDXVYvccsIcXn n4kIaUfayz+wmH1/nMt/sakv0+X0vTvvSmtpI6hjAQkO0iuGup30qpXOVBxPG9JF7a8w d5ynsFZgPa/Zo8ZXlm8ay8L4YPqRSppapDvtbiPbV1wIUHzMTPWcURM+2+DduekAJcvm AV8Hw2+8D0forJSJv/R5wmHZL1bPsgQTgtULxq/8eJeTosA4iCpVxzT9+C93Wk4t6hGX TOeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oAOXTcwf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mn18si3007773pjb.89.2022.01.26.07.07.20; Wed, 26 Jan 2022 07:07:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oAOXTcwf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235875AbiAZBcG (ORCPT + 99 others); Tue, 25 Jan 2022 20:32:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232531AbiAZBcE (ORCPT ); Tue, 25 Jan 2022 20:32:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83CB1C06161C; Tue, 25 Jan 2022 17:32:04 -0800 (PST) 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 18480615BE; Wed, 26 Jan 2022 01:32:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FB0AC340E0; Wed, 26 Jan 2022 01:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643160723; bh=5j8Og1hjoL1NLBflY/iku+q+IgVnwadiegZjmrsb2kQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=oAOXTcwfDHWLJLeChHxT1cLbBk3oKFT7ogwubviyDlVtBtQpYS8xgGC5hN/dwHLnc OCBPRPPYlFjSZ30zE65ETeIFK5wieqXVwENi4nYE0AmvH/xDNdhCI7iz8Tcy0hIq6c /BQYoitVsUpHRVE87JiG2Jj+hKClMwttXgzhQ8EF7Ir9gpdud1NK/zbD0G/+pZQlPR VvJXKm/x4txFZWsuYu5PUouCJP8gIGSx3Tb/VtJbe0jEyc6rXPT8OGj35wVQPhnBLF P7eFR4VxE/2FgLoj00icRRjsorXlai7NTI/LIf52UafWUkrgMpyWygFnc1AsQlcJBt 48iE0fOYMWmog== Received: by mail-yb1-f170.google.com with SMTP id p5so66800019ybd.13; Tue, 25 Jan 2022 17:32:03 -0800 (PST) X-Gm-Message-State: AOAM533O/3Do1OMdfBlHNK6af9MXx4XHc3GSrx/RUj5ePK4QxvAsFzNB XZaa6j/mu98RG9IlzeZ6up26xoZiHHsIJMEBSkw= X-Received: by 2002:a25:8b85:: with SMTP id j5mr32153498ybl.558.1643160722604; Tue, 25 Jan 2022 17:32:02 -0800 (PST) MIME-Version: 1.0 References: <20220121194926.1970172-1-song@kernel.org> <20220121194926.1970172-7-song@kernel.org> <7393B983-3295-4B14-9528-B7BD04A82709@fb.com> <5407DA0E-C0F8-4DA9-B407-3DE657301BB2@fb.com> <5F4DEFB2-5F5A-4703-B5E5-BBCE05CD3651@fb.com> <5E70BF53-E3FB-4F7A-B55D-199C54A8FDCA@fb.com> <2AAC8B8C-96F1-400F-AFA6-D4AF41EC82F4@fb.com> In-Reply-To: From: Song Liu Date: Tue, 25 Jan 2022 17:31:51 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6 bpf-next 6/7] bpf: introduce bpf_prog_pack allocator To: Alexei Starovoitov Cc: Song Liu , Ilya Leoshkevich , bpf , Network Development , LKML , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Kernel Team , Peter Zijlstra , X86 ML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 25, 2022 at 5:28 PM Song Liu wrote: > > On Tue, Jan 25, 2022 at 5:20 PM Alexei Starovoitov > wrote: > > > > On Tue, Jan 25, 2022 at 4:50 PM Song Liu wrote: > > > > > > On Tue, Jan 25, 2022 at 4:38 PM Alexei Starovoitov > > > wrote: > > > > > [...] > > > > > > > > > > In bpf_jit_binary_hdr(), we calculate header as image & PAGE_MASK. > > > > > If we want s/PAGE_MASK/63 for x86_64, we will have different versions > > > > > of bpf_jit_binary_hdr(). It is not on any hot path, so we can use __weak for > > > > > it. Other than this, I think the solution works fine. > > > > > > > > I think it can stay generic. > > > > > > > > The existing bpf_jit_binary_hdr() will do & PAGE_MASK > > > > while bpf_jit_binary_hdr_pack() will do & 63. > > > > > > The problem with this approach is that we need bpf_prog_ksym_set_addr > > > to be smart to pick bpf_jit_binary_hdr() or bpf_jit_binary_hdr_pack(). > > > > We can probably add a true JIT image size to bpf_prog_aux. > > bpf_prog_ksym_set_addr() is approximating the end: > > prog->aux->ksym.end = addr + hdr->pages * PAGE_SIZE > > which doesn't have to include all the 'int 3' padding after the end. Actually, we can use prog->jited_len in bpf_prog_ksym_set_addr(), right? Song