Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5894378rwl; Tue, 4 Apr 2023 05:21:12 -0700 (PDT) X-Google-Smtp-Source: AKy350bIWuHWrhD2ZFYLEBjDmyWYhgJk62UHtu7pCvFU0ejpU3NceV1VHAcWgy2xUD0LrieXuo8u X-Received: by 2002:a62:7bc7:0:b0:625:c048:2f81 with SMTP id w190-20020a627bc7000000b00625c0482f81mr2326758pfc.32.1680610872187; Tue, 04 Apr 2023 05:21:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680610872; cv=none; d=google.com; s=arc-20160816; b=S2/e9eKijR7W5bMrsCzYJQVuKR6Qx8jH+3UBQv5m7tz2AiNsJFyJBlCniHP11cL4ZG BdpbVnBeCXeZftGvAd5aOvR9rHCJOowEifgZk/wlfFR4mUUDDEa1b6I+FZijNq5q0Tyw umSUh7oDy7zdyOGunUU4u0UnFqKDXoq+KGVTZncobe/Ly5VNC61RGVCZosutKaK9jTTa hXGDKhmjdDldLvuCvkSW1Rdqx5u4451d+dEAf/SPxQUpAM+3MngBdRii1vwUUBqnwf6D KGM4hSkzSCi5KZWBlWZ4FTX537/fnPq2zJNrFEN3UimLjlhDcMuNslVgwi96E0cedWj8 3U0w== 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=1FlXMDdCERweSivjHZ7/5B+1YGIBAwVG5BfESYtf7Lw=; b=iH45cZJeJOZdYzRPE0p7++/cf7f5Un3AliPk51/3Cm0edZbTqhpUUhn/yrHAbMXbvL jFlforZn0naCb5jMeBQnZR5HO6bftvI7bcgwaLPty9cseuk/pITemIIEZ/NMjs58kG7Q 1h/+JloK9otpCtw6yGOytk9oYgBEizv6ra4v2pNt/Liv8PaCG9easTMK+tRhEHzCymBp 12kBTrZNbD/CA4bCV8xolrT3R21Gp6T5T5f/6k85DgSp1Nc7gAZgk4DYoUM6RQErizix oLmiWUqBpi5rjJFEQr9ljqCgUgKTU0ZUzWxiTO5zUl3XIsiWdlPGqTxFYc79PopdxOEg rW+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dectris.com header.s=google header.b=YX8mzm+G; 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=NONE dis=NONE) header.from=dectris.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v8-20020aa799c8000000b00625791bd85bsi10344563pfi.155.2023.04.04.05.20.59; Tue, 04 Apr 2023 05:21:12 -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=@dectris.com header.s=google header.b=YX8mzm+G; 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=NONE dis=NONE) header.from=dectris.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234852AbjDDMTm (ORCPT + 99 others); Tue, 4 Apr 2023 08:19:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234438AbjDDMTW (ORCPT ); Tue, 4 Apr 2023 08:19:22 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7129A3ABF for ; Tue, 4 Apr 2023 05:14:03 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id ew6so129618693edb.7 for ; Tue, 04 Apr 2023 05:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dectris.com; s=google; t=1680610442; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1FlXMDdCERweSivjHZ7/5B+1YGIBAwVG5BfESYtf7Lw=; b=YX8mzm+GaExr+LtZQZLQbjXBf1wS5hKRbNWLvbv1HjVUsM43EMylri0DSwQKzYdOPA niP9hMX/S7wflAS3uaIVpxFRjuTyNgSicuyHS4XSu+waAvO2edBguxqRD1aXbI5dP9mJ vDVmJ//mmpj6c0Mml6AJnkPMLTXJsMWBWxUpU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680610442; 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=1FlXMDdCERweSivjHZ7/5B+1YGIBAwVG5BfESYtf7Lw=; b=INgtywGHcyodWswACL9PXdooI7G24q39zX9wNQ+X0OQ1gPHmHNlBeLgtXegcImN2mZ S0ltcDDyB3nnA3/7y84UyvSy2lravjVNR1lpgKCNNJPRjpso9jY6JJ9F0LO/bl/P3kdp QA1pGfYJ+MkrnMgZ73ROzBgHnVmr0Q0KF6jb9SXO4x7LNgz6p9Fdaa0BumucObKUlPUs COmKpfiTeUzugWHq8mRK8oHowH+WgloV97XMtarF6k0QPugnjfeHWKgy9u7NAfXIt3ej VT6JI9ZZ45deC1brkMNnRVjIwKbaUygRPpsVYuE873i+ljAit+HC5PmncPcXnVPlkw5o XfMQ== X-Gm-Message-State: AAQBX9divoFIDmELkycZaMSqMEnm2OMcgS/58hRChIzCsOEwqRSlrxQI iNOPDqZSmSKYs5AirC9COnYPcRpqcMT1NxYL/F5png== X-Received: by 2002:a50:8d54:0:b0:4fb:7e7a:ebf1 with SMTP id t20-20020a508d54000000b004fb7e7aebf1mr1266924edt.6.1680610442009; Tue, 04 Apr 2023 05:14:02 -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: Kal Cutter Conley Date: Tue, 4 Apr 2023 14:18:42 +0200 Message-ID: Subject: Re: [PATCH bpf-next v2 08/10] xsk: Support UMEM chunk_size > PAGE_SIZE To: Magnus Karlsson 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,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 > > > > > 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. What about when CONFIG_HUGETLB_PAGE is not defined? Should we keep it set to PAGE_SIZE in that case, or would you like it to be a fixed constant == 64K always? > > > > > > > > > > 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. OK