Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3596634pxf; Mon, 22 Mar 2021 10:05:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1T36r7dattrzvuyoiW5ELo60b/CZSwAhTw0nO2/mFMuhejl3pjNHXvbImUOvsIdmV7Ecp X-Received: by 2002:a17:906:948d:: with SMTP id t13mr781404ejx.402.1616432722590; Mon, 22 Mar 2021 10:05:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616432722; cv=none; d=google.com; s=arc-20160816; b=DO4rePGmS3GmRkgfpiMBv03SRJ8jfdV3gqQZ/lGMk1un5D9OF4a28aUV0asFmOT/Ft YFyQKeEstUB/W3Np2IA5zYrJZlCVp13NNwVbzF2I4j/B6sG4/dVHWnj7PuE395zlo/ul 2Iq7j/6POEwaja4XYZn7+7Xg6l6nZd4U5md7jKEfucVLOZLwDYKqmh6cVsqokczn37zb Xd2b4obuekpanJchjMe+aFfW4iQZ0ZwtMBAP+N7flHCzdYHv2rd+u6Ty9cHvMW0sKQu4 4i9rKQpTkB9BnaQyRzVT2FaDcfT/KEMGd0ENMWYv9yIZlHBhklmrfvYjqIRrD3hR2Q+m +Z3Q== 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=HfDDxe/8lIcZn5jkUVlEburZZGH3fn528crkNlTq2KlNjMLt7y4R43vp42IIA1yFcT VngEzCoaMTn5RL8T4jUz1fOomK82jfPnip20+iFg7k7CCUG8wXG1GuRX7/ABDL7mJ8Zf JW/+9ccTG8FpUsUyttCqBIHZgvR/g0Eoi66Y6OfV4r0+eUek4cflf1J/N0iirfkqFFj6 KoKGdLnAUfcRABd/WcWtye1A5iiwihntV10eRCGw3iS/4RyeaYwq6E3iMDrjouSx24KE 4Y5oDztgI2wYmBfGU1zauusRehN0QpBD6xqTGLiPAvmGyc71SwlzrVqSZl0gEDUZ/o/6 bexw== 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 ci8si11530097ejc.428.2021.03.22.10.04.58; Mon, 22 Mar 2021 10:05:22 -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 S231854AbhCVREC (ORCPT + 99 others); Mon, 22 Mar 2021 13:04:02 -0400 Received: from mail-ej1-f53.google.com ([209.85.218.53]:41648 "EHLO mail-ej1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230252AbhCVRDg (ORCPT ); Mon, 22 Mar 2021 13:03:36 -0400 Received: by mail-ej1-f53.google.com with SMTP id u5so22497421ejn.8; Mon, 22 Mar 2021 10:03:36 -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=Nn3DEO+5ZRwC+sqPxUomMSosil8ZsSmFHDRoqTrAiFH1HnerpjAPBpGno3Jca3q54O nE8ck5VOBK6/ju3uXhyfs5YKDeYJn77obcTvRhlxl/C+zmnnuDMMVIDNMn5GsXYXS6vz K2sw7LXt7omkmvRud/MKcN95Rq9E1qMDNK89krRpMPjnYkN+FfqExtckloZ4fKbXOW2x DqwU3jLajuk7RETZ/j1ofk9EiD4akR/vWxxY2Qd7or3FE+JmVPo3lDmyJOFSkJOe8UIl IAzQBjQHTD1S2LKorsRxkRf3uNZa7EeJqrcDgyUJQ654jcyZsiIEaBF9tDgzjyUZa+eO ++OA== X-Gm-Message-State: AOAM531aulqwuSvmkP6aNuVrRqE+vL8WyYTc+vWBmuV/imP9fvrXtTVq u7nTLZJq1ileq77ATF1pXL3DWdORLic= X-Received: by 2002:a17:906:23e9:: with SMTP id j9mr799383ejg.78.1616432615404; Mon, 22 Mar 2021 10:03:35 -0700 (PDT) Received: from msft-t490s.teknoraver.net (net-2-34-63-208.cust.vodafonedsl.it. [2.34.63.208]) by smtp.gmail.com with ESMTPSA id h22sm9891589eji.80.2021.03.22.10.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 10:03:35 -0700 (PDT) From: Matteo Croce To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jonathan Lemon , "David S. Miller" , Ilias Apalodimas , Jesper Dangaard Brouer , Lorenzo Bianconi , Saeed Mahameed , David Ahern , Saeed Mahameed , Andrew Lunn Subject: [PATCH net-next 1/6] xdp: reduce size of struct xdp_mem_info Date: Mon, 22 Mar 2021 18:02:56 +0100 Message-Id: <20210322170301.26017-2-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210322170301.26017-1-mcroce@linux.microsoft.com> References: <20210322170301.26017-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