Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5207140pxb; Wed, 26 Jan 2022 07:06:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwhMpl2UMumsw+f14pYVBoVxJbURp2xvX+E5hj9bwyCALNehvSHVzKci2Nyy3VWPcTd6vFL X-Received: by 2002:a63:9144:: with SMTP id l65mr14270729pge.396.1643209617797; Wed, 26 Jan 2022 07:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643209617; cv=none; d=google.com; s=arc-20160816; b=JNK3fUct6MAFtoe71IFweEopYqb4mETRMFDE0ec9e+1QgKccgpz+TVZiXQG2J+wT+w TjMrMqYtRIIOiNgTffrlPufhfKcT85lMi+FYIXNznSAZkJ2Rw2oA30KrXBsUq0xE1w9q psPmBHea2wey/wwHUWNMgCQ3icezpWMBLlMS57nB1iB8M3A2qUv0B8MH/2Mch6Tiir6Z ZvDvSkspNa7oKhtoEWzSw+KCzpQJWIL6H0zvcMKXNO+ERvkyVXK+lARjzovSK/rbZ4N9 7cDfzweRGE9Huqh71XZM2BTOHVGlEtNu1lN5er4kG+p39KxKPb6+BjwyOyXQP4yn1sli CmUw== 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=FkS39UrpEkzFr/DTYFSIJn1KCTzZPC1mxVOUkRICgZk=; b=MfFj96irq14zC5saT2gr2+JZBQAihxgvVQ2iPQqsHA/v0TYln2Id0Lojo6mGR0+YIi E+Zpp/MDpuyYZsstHMHKgK5T+onXkBXeon7wwqQiDKrOmTOom0wHzhHmKMS81XN2RyVJ DjMprXrHFC1e9WZlsMnWo6Xp5+4h/ePw5dXjOVpT4d2DUtVH0Jqo0P8o569OqvtprrW3 N61FmZrr5MkibHnffKG622Hs/n7IA2M7qsCW447SCd2ofKqlWgcTbva/zRHe7lly2YVQ kdxn6g5FqblcivW4hNB+/ErJV2kNHIaF1+C7NvTP7Hw97KZqun/4SRuyekEm/9Y2EtVm yFPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R0RYE+Bx; 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 d17si1918134pfj.152.2022.01.26.07.06.44; Wed, 26 Jan 2022 07:06:57 -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=R0RYE+Bx; 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 S235861AbiAZB3J (ORCPT + 99 others); Tue, 25 Jan 2022 20:29:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232531AbiAZB3G (ORCPT ); Tue, 25 Jan 2022 20:29:06 -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 01DC3C06161C; Tue, 25 Jan 2022 17:29:06 -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 985656147F; Wed, 26 Jan 2022 01:29:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05DD9C340EB; Wed, 26 Jan 2022 01:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643160545; bh=3Dl5gg1FU6a6i04eoWLrDaih8y7yDVumhdw/24i57HE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=R0RYE+BxhV4bY83+jclSD6SH+ZBgUlYwZpEo3PIqJz8S/UY9J7fPTnuCqzHucGQEa sztgs4zhzbHgqTRqQfsC0i7VNO4tIfhz57IVWXAwhCudMFxlAxHgvwdlk5I/hQA0SI 3r7JsBwwM5sanTPthplfroB0kM+YYIp1cPx7ZgnR00orSmf+z8G4VIDy6FiYDI2ABt duKIVib721rP4aob2ByNqtkxTgSNzxg9poj2lKV0Gp0cSWtv8zomD/FBSiKpguswVB F/AIMzJxgIfS3ZLp9CWqZLsQzznHLRwkWyMwQB/DnFsnObnr7QRL6actiday4TZwZQ mdgcR89N4rbkQ== Received: by mail-yb1-f182.google.com with SMTP id c10so67040778ybb.2; Tue, 25 Jan 2022 17:29:04 -0800 (PST) X-Gm-Message-State: AOAM533k1YyhAQLaz4E+4FIOgzbPLXidTyowq7nujKr0zVBXGXSCiVjm tgXi3BdCWCdGtRQmcFRW+mbV/iJkh/t3cWzA5iU= X-Received: by 2002:a25:8d0d:: with SMTP id n13mr34317692ybl.208.1643160544095; Tue, 25 Jan 2022 17:29:04 -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:28:53 -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: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. > > Or add a flag to bpf_prog_aux. > Ideally bpf_jit_free() would stay generic too. Both ideas sound promising. Let me try to implement them and see which is better (or maybe we get both). Thanks for the suggestions! Song