Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp875795rwl; Wed, 12 Apr 2023 05:30:11 -0700 (PDT) X-Google-Smtp-Source: AKy350Z0lp8ASEd+s/u00kmGJvUapYHkFzJAGgIJC77gOBNotWJw/ChfMXFNUsgnyBr5HBH3Q3th X-Received: by 2002:a05:6a20:7b2f:b0:eb:a859:e870 with SMTP id s47-20020a056a207b2f00b000eba859e870mr2085848pzh.20.1681302611571; Wed, 12 Apr 2023 05:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681302611; cv=none; d=google.com; s=arc-20160816; b=uCCm9dGRkTBAzSAlhr9OxaHN/1xn8hnshObz/KsMMQ7HI3D1mACW7jrtA1oK44i00Y 24bgmO3lICxl4yqHGnmTrBNKmhfCGaegi5L5Olp0MHCo8BMms+gg8ngO812c1c5hqZH4 k+kHCn+p39fnLw+IufTAnyxJTGtdhSIqR9ef2jUKZxSKyyWIhZuSPyZ/ai66kbPb724G OWS6equbcExbuEUdu7DwpLx+ce9ryOzQURKeLUUwda2aBuX8386Dwm21HfCcaLrrQfEI 1PIlMYbWaL9R6u2skYmVvmK2mDThF9FwR6UxfO7JivhJXwVXBX5fYNcmcxdGKZKBsCAS UOZQ== 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=LUWRNNE/JZ+baYmjcl+NKkyo+ch4BXrt9V/cFSfdS9E=; b=nTQY4KgHsLf0E5ecCFCmb6hBQf12uGvn4G7tsQLq0n7oyh5EpODm+7wHX2h152NLby xgFvApQvViFyWUQkyWOCGwEAy6otjeRPZlfeGIFKqfuJHNc/pb8gi2nhoq6QI0tJUgpA 3vXIF5zhxARdWm/LjmxUM9aDYu0TJ91rDlT+h1eOk6QPvkdbTPbQTTkIc6ZzRV7BXcjw AcHemk+bcKeGeO7fO9AooKfvBuY8MySgFn+oJmjHTil8HBAmk1U6S9RdHmbVDkfcRQwo GPZ3YTzbEuI1A8B+MksqHCyQJjuW0MVgSJsVXMNADBfT0IJ/Mj0ehCmZTWBDS70Lj9aV BRcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=e0roAdor; 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 v185-20020a6261c2000000b0062545446afcsi15373027pfb.165.2023.04.12.05.29.59; Wed, 12 Apr 2023 05:30:11 -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=20221208 header.b=e0roAdor; 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 S231395AbjDLMX7 (ORCPT + 99 others); Wed, 12 Apr 2023 08:23:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjDLMX5 (ORCPT ); Wed, 12 Apr 2023 08:23:57 -0400 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 822B772AB; Wed, 12 Apr 2023 05:23:46 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id c2so790408ybo.9; Wed, 12 Apr 2023 05:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681302225; x=1683894225; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LUWRNNE/JZ+baYmjcl+NKkyo+ch4BXrt9V/cFSfdS9E=; b=e0roAdorSyZN8o45fnTNqHMlgok99sbVKgKWJBZYlxRxKoxRZ3/kteLoTHcQNkwdrc L88YfpsHnhkxrpvXkWURXN/JnM1QDt9E+Soo9qy6uNfwaZevtf95xZ65xOh0LsmXV7o9 eQHcQarWEzYc1bzgbtB8zeHSlpmMEgxAKlYFizNJ0wc5DHY3kNyP7uV42coWsrClDeSN 2VVXp6ltyACbJTretkzPOefjhg/59ys6FBts4E+n4giyZYzU+s5hxvguSWhCBW7IdOHd keU4ASVDfU4GyM0hO2+vkGYGdCaU49XGUxOgSlEgiL/cixRNx1lnTn0C7W4EKDeTkQX7 NweA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681302225; x=1683894225; 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=LUWRNNE/JZ+baYmjcl+NKkyo+ch4BXrt9V/cFSfdS9E=; b=QJelOKWqyAlinAqFlSeROPzfySfye93P1lKJavyggb53HaGBQO9F9ZcIvifBzSkc5T 9z+lAaOIZnal1V0sCT42OsSahCv3zU3lEfkfkpW5R+BDtZM+2ngJqSKUmv6NG/GgsXRX oRzzUDko6TB0Esr625AHYZY7l8Mv2YDjt1SK5XYzbR2JD54wTrTlOJ9UdbA2wo6XMUFF MLqFy4LDv446jCDgHbYmmSrjoyYUZXCvYSoGWoGM4GSjoh5gbsPQVd4Dh3oj6K3TMqD6 80yB/B113Yx7N4S8U5Iv3EgVlueGAszh6w0FDSzZWTPXLdcAWmpDb7n3hnOIzKKWvV5L vAVA== X-Gm-Message-State: AAQBX9e00V77xMwJByQ1wCcFQwEdfDLTX/gb9QcfUrM/qNl0ziwtouvR ZbJX1tmKBV/AHPzwKAkRbis0luV2/otEs5pV2q4= X-Received: by 2002:a25:744e:0:b0:b8b:f61e:65ff with SMTP id p75-20020a25744e000000b00b8bf61e65ffmr3908986ybc.5.1681302225713; Wed, 12 Apr 2023 05:23:45 -0700 (PDT) MIME-Version: 1.0 References: <20230410121841.643254-1-kal.conley@dectris.com> In-Reply-To: <20230410121841.643254-1-kal.conley@dectris.com> From: Magnus Karlsson Date: Wed, 12 Apr 2023 14:23:34 +0200 Message-ID: Subject: Re: [PATCH bpf-next] xsk: Simplify xp_aligned_validate_desc implementation To: Kal Conley Cc: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Mon, 10 Apr 2023 at 14:24, Kal Conley wrote: > > Perform the chunk boundary check like the page boundary check in > xp_desc_crosses_non_contig_pg(). This simplifies the implementation and > reduces the number of branches. Thanks for this simplification Kal. Just to check, does your change pass the xsk selftests, especially the INV_DESC test? If so, then you have my ack below. Acked-by: Magnus Karlsson > Signed-off-by: Kal Conley > --- > net/xdp/xsk_queue.h | 12 ++++-------- > 1 file changed, 4 insertions(+), 8 deletions(-) > > diff --git a/net/xdp/xsk_queue.h b/net/xdp/xsk_queue.h > index dea4f378327d..6d40a77fccbe 100644 > --- a/net/xdp/xsk_queue.h > +++ b/net/xdp/xsk_queue.h > @@ -133,16 +133,12 @@ static inline bool xskq_cons_read_addr_unchecked(struct xsk_queue *q, u64 *addr) > static inline bool xp_aligned_validate_desc(struct xsk_buff_pool *pool, > struct xdp_desc *desc) > { > - u64 chunk, chunk_end; > + u64 offset = desc->addr & (pool->chunk_size - 1); > > - chunk = xp_aligned_extract_addr(pool, desc->addr); > - if (likely(desc->len)) { > - chunk_end = xp_aligned_extract_addr(pool, desc->addr + desc->len - 1); > - if (chunk != chunk_end) > - return false; > - } > + if (offset + desc->len > pool->chunk_size) > + return false; > > - if (chunk >= pool->addrs_cnt) > + if (desc->addr >= pool->addrs_cnt) > return false; > > if (desc->options) > -- > 2.39.2 >