Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1708168pxf; Fri, 9 Apr 2021 15:39:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqWBsbc47xCaDlfjbxK/U55QYh6g6Sl3p8TXB936RwmfWdaqUfIdTXq+4GB3AH5OK5TuVR X-Received: by 2002:a17:902:8495:b029:ea:9b46:f311 with SMTP id c21-20020a1709028495b02900ea9b46f311mr4023976plo.0.1618007961090; Fri, 09 Apr 2021 15:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618007961; cv=none; d=google.com; s=arc-20160816; b=yz6gnQRLY7DfzjImXbjZN31YQwpB83siprTYZ37I3+vWR947KrtIbtcfNDjrxHPTNy 2K7waDgHHshz6J0kDD796W1Cl0MVsG7Pdj2q+pk2QtkJS3l4oYxKDRO3Cl5rxVBO14mJ 3CSed4Tkiozo1+vcvIf1ABr6hdak6wQMqs4LTeZ5xB9E3Vb4aAvSS/f2enUGcQdTC9aV sT/QL55/n8HLFixqVAhTSmMfeSmqrdLon3ZiYG+uJoClABgnphtDc4Js+mbAMwTli2+J +sX6L4Zdt0JTLCsmss1BpGTb+6KCBVzbq7JYlXkhIAzgWiC42p6tIEbi0a/K1EMGgrMs tIHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NBKBwFnLR6KheF+0+jTnrdx81GBF+PEZpOcMgLUdP0I=; b=F8rUu7QGRbGpCD+vOYqfwLd2GSckj89JjGshmASwWvjnvuURmYb6NxOMfnxB5HV7N2 dwqALnH3GAwDMuApm4OAn9ji/6yWqbB6SklQQ/UWl52/f0Hx2MCX/FuOlbqDlun+H8Bf rU+bLQwCRMjNz7FbieuohsCeFQq9GB5kTS3C5On9fLaXzb5nfGAZPAFTr9o0vCcH/5+G 5ERnM+FkUKSa4KAT2XxXj65KZOAgTograxnJUb3bsvruSDAr11PuCLsC1pHTHpRzbntJ zfoIqBtx7L6N0rKHvUia97o0lSQVuPnJhfIgs1QVAj05+94Aw2WaFpC36RfSQw+Q3th7 Al0g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t63si4208689pfb.267.2021.04.09.15.39.08; Fri, 09 Apr 2021 15:39:21 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235107AbhDIWii (ORCPT + 99 others); Fri, 9 Apr 2021 18:38:38 -0400 Received: from mail-ed1-f54.google.com ([209.85.208.54]:33571 "EHLO mail-ed1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234602AbhDIWih (ORCPT ); Fri, 9 Apr 2021 18:38:37 -0400 Received: by mail-ed1-f54.google.com with SMTP id w18so8341047edc.0; Fri, 09 Apr 2021 15:38:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NBKBwFnLR6KheF+0+jTnrdx81GBF+PEZpOcMgLUdP0I=; b=QNcDKWg3i3l0fzCFlmYy+3oSUs7xyv3i8GSFrsXg7YaGpUxHqKgh2ztO/FJHSpxRld RWmXl0qgtyDjAhfHLJCSdzUnQXyPp5tjw5ufJ7NFKiO3KKFwdH8C1NdZznZYPBcGINz6 FU1cYQpWY0nBLXjJb79rgLXYFr1KQQKCBxNFE5GyMuupfLmupENS2gZNyRqOZPLVhLi2 J4LCwIV5o/StbIfRRLs+WKWJEJffn5daUScMsyZI+s46oG3ZJ+xRtJIzzfrqmViEAD4c un5ae6IA3tp8a+TWGI5SH1Y1qa+Zw9vNHkm4eofpP4SqFU//7A9HsFYqZ8Uz52w8+63v yNaw== X-Gm-Message-State: AOAM530gq5sgiBYsek14KDwLVWXfg7F77YCi8kN8DRnWdwPrxjfNx2f2 gQBFJmj88iNAdUvxWiDeNG3f7wH5ermszQ== X-Received: by 2002:a05:6402:51cd:: with SMTP id r13mr19553933edd.116.1618007902253; Fri, 09 Apr 2021 15:38:22 -0700 (PDT) Received: from msft-t490s.teknoraver.net (net-93-66-21-119.cust.vodafonedsl.it. [93.66.21.119]) by smtp.gmail.com with ESMTPSA id s20sm2108726edu.93.2021.04.09.15.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Apr 2021 15:38:21 -0700 (PDT) From: Matteo Croce To: netdev@vger.kernel.org, linux-mm@kvack.org Cc: Ayush Sawal , Vinay Kumar Yadav , Rohit Maheshwari , "David S. Miller" , Jakub Kicinski , Thomas Petazzoni , Marcin Wojtas , Russell King , Mirko Lindner , Stephen Hemminger , Tariq Toukan , Jesper Dangaard Brouer , Ilias Apalodimas , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Boris Pismenny , Arnd Bergmann , Andrew Morton , "Peter Zijlstra (Intel)" , Vlastimil Babka , Yu Zhao , Will Deacon , Michel Lespinasse , Fenghua Yu , Roman Gushchin , Hugh Dickins , Peter Xu , Jason Gunthorpe , Guoqing Jiang , Jonathan Lemon , Alexander Lobakin , Cong Wang , wenxu , Kevin Hao , Aleksandr Nogikh , Jakub Sitnicki , Marco Elver , Willem de Bruijn , Miaohe Lin , Yunsheng Lin , Guillaume Nault , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, bpf@vger.kernel.org, Matthew Wilcox , Eric Dumazet , David Ahern , Lorenzo Bianconi , Saeed Mahameed , Andrew Lunn , Paolo Abeni Subject: [PATCH net-next v3 1/5] xdp: reduce size of struct xdp_mem_info Date: Sat, 10 Apr 2021 00:37:57 +0200 Message-Id: <20210409223801.104657-2-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210409223801.104657-1-mcroce@linux.microsoft.com> References: <20210409223801.104657-1-mcroce@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jesper Dangaard Brouer It is possible to compress/reduce the size of struct xdp_mem_info. This change reduce struct xdp_mem_info from 8 bytes to 4 bytes. The member xdp_mem_info.id can be reduced to u16, as the mem_id_ht rhashtable in net/core/xdp.c is already limited by MEM_ID_MAX=0xFFFE which can safely fit in u16. The member xdp_mem_info.type could be reduced more than u16, as it stores the enum xdp_mem_type, but due to alignment it is only reduced to u16. Signed-off-by: Jesper Dangaard Brouer --- include/net/xdp.h | 4 ++-- net/core/xdp.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/net/xdp.h b/include/net/xdp.h index a5bc214a49d9..c35864d59113 100644 --- a/include/net/xdp.h +++ b/include/net/xdp.h @@ -48,8 +48,8 @@ enum xdp_mem_type { #define XDP_XMIT_FLAGS_MASK XDP_XMIT_FLUSH struct xdp_mem_info { - u32 type; /* enum xdp_mem_type, but known size type */ - u32 id; + u16 type; /* enum xdp_mem_type, but known size type */ + u16 id; }; struct page_pool; diff --git a/net/core/xdp.c b/net/core/xdp.c index 05354976c1fc..3dd47ed83778 100644 --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -35,11 +35,11 @@ static struct rhashtable *mem_id_ht; static u32 xdp_mem_id_hashfn(const void *data, u32 len, u32 seed) { - const u32 *k = data; - const u32 key = *k; + const u16 *k = data; + const u16 key = *k; BUILD_BUG_ON(sizeof_field(struct xdp_mem_allocator, mem.id) - != sizeof(u32)); + != sizeof(u16)); /* Use cyclic increasing ID as direct hash key */ return key; @@ -49,7 +49,7 @@ static int xdp_mem_id_cmp(struct rhashtable_compare_arg *arg, const void *ptr) { const struct xdp_mem_allocator *xa = ptr; - u32 mem_id = *(u32 *)arg->key; + u16 mem_id = *(u16 *)arg->key; return xa->mem.id != mem_id; } -- 2.30.2