Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5842998rwl; Tue, 4 Apr 2023 04:38:30 -0700 (PDT) X-Google-Smtp-Source: AKy350aT/eRxlo4LJoo2lyDfuf8yLPwILAiajKSROMPkb6rtWqYQU9M0UxBpo0TBLy6QjNJ6LV0l X-Received: by 2002:a17:906:3494:b0:930:fded:5bf2 with SMTP id g20-20020a170906349400b00930fded5bf2mr1930135ejb.52.1680608309798; Tue, 04 Apr 2023 04:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680608309; cv=none; d=google.com; s=arc-20160816; b=bQbavH1POA2WKD+sWWQQloA70bAXT5+wWDeVq29XQYLedNRIt7iX8pl1NMukTAq78Q vS00zGzIYROksprbGS4pjz0YKifmFWiToFwTrrU1CzMGr/9KXBHlyX+GDhBo7naiFKsB lQ3VnBIM0e3MeQUwDMtndDps59rI+DqEedobIp7AXvShNZ5WH+z/bCQa/OUypCtn0ad0 mLDRwUTwqAOAsFGEliKRHv3uRpQuHYMpx6xkrrrN6vwYQVvAirEB+Mtkw/ccZNJeP0cy TFra5VZh0kTWh+HrmARJ53+8wTisy9ZfF/KOpa+bynnf9IYhdPlYJGmlak7SOe/IaEAU qXBw== 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=gVo5EF32hJ+j6zLMjucS/chjw/jsmoSQqHwPbkJqces=; b=SVHqnfiSGEs4LmOnukjKaKFtOeYeMVyEuLiSPG7JCXDFNxt3JhkcJzvPn3e5egnj+W hbgikti7/KHfgQvJdA6TeFPunUa52RZqkdbkyZZMiY1EsVQHgNNE5iQdnL1OVj6Ddn1l NNAa6P395Nkn77do8sa1acrYQboFj4QEQfeLV9I6/NCjV7ukXqbW1EmK3TAqzBK1WjNE BKmQSgVA8Pk8ix3OShUOrJFdrob2IMsc4v7aDFitBUJXlTZqP80y1aiobmDFlcg3EZuc AO1YyRi4W+0NKsOMLlhWi1fCCfZdXuL1GzS24m8ToQZvJPWZSifzIXJgsMgqIGLaj8wt y97g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LwsfY1Ot; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j17-20020a170906105100b00929d26a82d8si7458962ejj.206.2023.04.04.04.38.00; Tue, 04 Apr 2023 04:38:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LwsfY1Ot; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234659AbjDDLOf (ORCPT + 99 others); Tue, 4 Apr 2023 07:14:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234639AbjDDLOd (ORCPT ); Tue, 4 Apr 2023 07:14:33 -0400 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DB7C1FEA; Tue, 4 Apr 2023 04:14:32 -0700 (PDT) Received: by mail-yb1-xb2a.google.com with SMTP id cf7so38212021ybb.5; Tue, 04 Apr 2023 04:14:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680606872; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=gVo5EF32hJ+j6zLMjucS/chjw/jsmoSQqHwPbkJqces=; b=LwsfY1OtmyxDYjVpbBC59BNM9J4LMypl3khFXHuBY6BEJtuHWVF6eb2F/OPKgnEv7J Fs7PmMuNKaVneD5uzcgczfMORk+rFTjGoJQYf5WGXdZI7yJ4ItoMZTwSplPFDvwkiqgx A2InUYXJUwyh3pMRhwCIzGpMA9hTMDKGc26zJkwrcVsupUyt/7sfz2PT/FL6FH1Z+VHz KGG2Z97W0knDhGwhVejX7yzguE0y1XYMjXcMH7cdhcbsr79czyq+9xQXV5grW21dHA+o MBZRSP/41aOgP4ZMKpwvTLlofI3hdYR4x98u55XVjt33ZLqI73CsIeQ5WIQ05Yokm5IH 1TOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680606872; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gVo5EF32hJ+j6zLMjucS/chjw/jsmoSQqHwPbkJqces=; b=ZGEUMW2hKo8XH6nATnOpH1yHiEmXWEwovl35dmP4jHOAKWtWGycxG20VtmFc9R8JCI WHfOqzxqwSwL4PaCHgbomVWTxgxm9bgLvUiHEGXtQPvvGtcAuNZzRnbJo3Q2xR7Lp/KL 8chnKZBkZyQh/E1z0bhQYXxHamvqkdaEP4nlUIyF446Osm8cgOQLeRFHTecmkPjSQ/IT L99FFduviVtsLr61FAfexPMKW9XJdnyYcEVtfOs6VQ4BFYrwM63ZVND1H5211qxgus2z 90kLo5nYlgF+iBYus0QfsDlMLP27cF6Jy19hPiWDzRpCqhS4HbQz/OwmZoz5Ec/+Zexe Q29w== X-Gm-Message-State: AAQBX9cc/TTIXy5ypZS6G9XirxIuZi6xgPeqf4o93+lBiZTODO3F6ovi ITUggykc2Yzb8fDN0MlLJe4lV98xjtgATyTKqJ0= X-Received: by 2002:a25:c401:0:b0:b76:ae61:b68b with SMTP id u1-20020a25c401000000b00b76ae61b68bmr1379110ybf.5.1680606871742; Tue, 04 Apr 2023 04:14:31 -0700 (PDT) MIME-Version: 1.0 References: <20230329180502.1884307-1-kal.conley@dectris.com> <20230329180502.1884307-9-kal.conley@dectris.com> In-Reply-To: From: Magnus Karlsson Date: Tue, 4 Apr 2023 13:14:20 +0200 Message-ID: Subject: Re: [PATCH bpf-next v2 08/10] xsk: Support UMEM chunk_size > PAGE_SIZE To: Kal Cutter Conley Cc: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 4 Apr 2023 at 12:29, Kal Cutter Conley wrote: > > > > > Is not the max 64K as you test against XDP_UMEM_MAX_CHUNK_SIZE in > > > > xdp_umem_reg()? > > > > > > The absolute max is 64K. In the case of HPAGE_SIZE < 64K, then it > > > would be HPAGE_SIZE. > > > > Is there such a case when HPAGE_SIZE would be less than 64K? If not, > > then just write 64K. > > Yes. While most platforms have HPAGE_SIZE defined to a compile-time > constant >= 64K (very often 2M) there are platforms (at least ia64 and > powerpc) where the hugepage size is configured at boot. Specifically, > in the case of Itanium (ia64), the hugepage size may be configured at > boot to any valid page size > PAGE_SIZE (e.g. 8K). See: > https://elixir.bootlin.com/linux/latest/source/arch/ia64/mm/hugetlbpage.c#L159 So for all practical purposes it is max 64K. Let us just write that then. > > > > > > > static int xdp_umem_pin_pages(struct xdp_umem *umem, unsigned long address) > > > > > { > > > > > +#ifdef CONFIG_HUGETLB_PAGE > > > > > > > > Let us try to get rid of most of these #ifdefs sprinkled around the > > > > code. How about hiding this inside xdp_umem_is_hugetlb() and get rid > > > > of these #ifdefs below? Since I believe it is quite uncommon not to > > > > have this config enabled, we could simplify things by always using the > > > > page_size in the pool, for example. And dito for the one in struct > > > > xdp_umem. What do you think? > > > > > > I used #ifdef for `page_size` in the pool for maximum performance when > > > huge pages are disabled. We could also not worry about optimizing this > > > uncommon case though since the performance impact is very small. > > > However, I don't find the #ifdefs excessive either. > > > > Keep them to a minimum please since there are few of them in the > > current code outside of some header files. And let us assume that > > CONFIG_HUGETLB_PAGE is the common case. > > > > Would you be OK if I just remove the ones from xsk_buff_pool? I think > the code in xdp_umem.c is quite readable and the #ifdefs are really > only used in xdp_umem_pin_pages. Please make an effort to remove the ones in xdp_umem.c too. The more ifdefs you add, the harder it will be to read.