From patchwork Mon Apr 8 17:25:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13621427 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DBA51442F7; Mon, 8 Apr 2024 17:26:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712597179; cv=none; b=cIm6vMBnbOLnuxzKtHpD4NNIyQjoqVC+Jcp1Hgds6uuxNzU/i/HAYrEKow/ITvXaGwi5E5bihN1Kov7WlDBbGAmJosuaEn9XVam3+MEMPqv1P51krBpSpnvCeHKEJK1LYYecYzfIXBshqO359q6DxBL4qahxw2lqgAZSeGJwIbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712597179; c=relaxed/simple; bh=Ymi8vcGeV5U25n5hHY6p/NSyc58XMyU2LXdmqZKED6g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KA41IKr0k17UzdvF0EPl2ZwvMx9+iqtu9EjCJTZAjrk7Fb18FWBLe104Q3kda+3HUSMpZ++RwmuYEpwjPbS/0C+EwC21Vipnp1ttdTUEdLaz/4RQc0TVXNWc5aSvLrEXSD4mWFUO3/BvzQpiK/TZgW1/bSPsSHIOIQFVMVxzLJc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-56e448d6f9cso1021673a12.0; Mon, 08 Apr 2024 10:26:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712597176; x=1713201976; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G8m6X0YutT7uWn1TO1PGQ+ufRs6DUh470J81GT16/S0=; b=cmIE5qQrQjWgxIzwphQ0tAidbQUzzAaTHintib9wLS9W0rDRIMW69c/1Q+cQc7IoCs QnXOPu/sbzMe5PJvTDNGCuZIo7Mb3p06EheGLpRbj10uxmplZ0gu4oCEB7sN2Y4NTyo0 Bt/xvg4hW5ymMRPHWYZSBras+OhveL5wkcV50zFqwPAG6oQZMVqcAeLDbSwPgAcqShiw 3ByjTjv+R7Z5pVeiucaFmtomAsbpvazqVT7Pq4cZHRBGb5ScKjdPIxD8poICBOsuiGJQ rkiLZAa4dQJe6HScl/S+iIafBReBPSKNr0ZSN17HOI7LUv6410wSKXMictspxKU9aUso zDhQ== X-Forwarded-Encrypted: i=1; AJvYcCUGe+jq3gKI2OZCuPvwe6xxEH+9w4jl9zVzfF71DBvBKze7L4mx6UYE+D3gzQz2bvdgUs+TlByeu/jEiWKHnz+zwXY4ayAc X-Gm-Message-State: AOJu0Yy4LkhLrCSQ3JDOrtOohzZ77bTQlP1DhXHUJ6RaUgCxW+qmdlcF WrL5SGdIO0ewShn+idsUzzLOwFPDtsGy+KA9Yu6CiRDhQwBOLGl2 X-Google-Smtp-Source: AGHT+IGVzn7W4dxxHSKD4W/Lzeimdl65qF2blvlokwb4FfjVnMdtNOBWixC3tZxzZdy3YL4UGchKKw== X-Received: by 2002:a50:d658:0:b0:56e:2148:f517 with SMTP id c24-20020a50d658000000b0056e2148f517mr6133085edj.33.1712597175640; Mon, 08 Apr 2024 10:26:15 -0700 (PDT) Received: from localhost (fwdproxy-lla-001.fbsv.net. [2a03:2880:30ff:1::face:b00c]) by smtp.gmail.com with ESMTPSA id b26-20020aa7c6da000000b0056c24df7a78sm4327079eds.5.2024.04.08.10.26.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 10:26:15 -0700 (PDT) From: Breno Leitao To: kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 1/4] net: dql: Avoid calling BUG() when WARN() is enough Date: Mon, 8 Apr 2024 10:25:53 -0700 Message-ID: <20240408172605.635508-2-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240408172605.635508-1-leitao@debian.org> References: <20240408172605.635508-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org If the dql_queued() function receives an invalid argument, WARN about it and continue, instead of crashing the kernel. This was raised by checkpatch, when I am refactoring this code (see following patch/commit) WARNING: Do not crash the kernel unless it is absolutely unavoidable--use WARN_ON_ONCE() plus recovery code (if feasible) instead of BUG() or variants Signed-off-by: Breno Leitao --- include/linux/dynamic_queue_limits.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/dynamic_queue_limits.h b/include/linux/dynamic_queue_limits.h index 5693a4be0d9a..ff9c65841ae8 100644 --- a/include/linux/dynamic_queue_limits.h +++ b/include/linux/dynamic_queue_limits.h @@ -91,7 +91,8 @@ static inline void dql_queued(struct dql *dql, unsigned int count) { unsigned long map, now, now_hi, i; - BUG_ON(count > DQL_MAX_OBJECT); + if (WARN_ON_ONCE(count > DQL_MAX_OBJECT)) + return; dql->last_obj_cnt = count; From patchwork Mon Apr 8 17:25:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13621428 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7A861448E6; Mon, 8 Apr 2024 17:26:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712597182; cv=none; b=YT6OyXmzqSky/Qv1dfBz2dG/5SfwX26AVavlKX3MSjtBPgcd9knAsO+SgRXMm5KfDvLtWBiqg4diTQFaoFl0srYrl0BeQurQm9u65mKiv4LuHAIMSPDKIqIuqDqeQOhX7eH1caOUlr6EwjKb90BdUqyddFI4LT16t8+Q5AcM5ik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712597182; c=relaxed/simple; bh=QPTI0Nkyu1TM5zoNdUKd64u7ifIX9UASRm9jdOshan0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V82wDhZT/+pQl4Yr+Q772hktDTT3VNJByg/0r+fgf9EtBbKToGlgkLkoJ3GhTvXzbgDNvzuhZzyrQqeixqzSvaq0Ju/tm2quFNJxhMFw28a1ujC0hi1qB82wdV3PH8hET5QSBhgd86Jr+kHxt52JxnFxcPAJebuEX1pej7B5j8c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-56e69a51a33so806103a12.1; Mon, 08 Apr 2024 10:26:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712597179; x=1713201979; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lEv54p1vC2qDsADoejwxZbGsBSC01L0fD1We714EtHU=; b=hNrhqdkvNKGu9tFxLaQ29uzV1fW/3AecZIEz33KGMPQjf8YG8Vy7K4ApTFn5fzz9/5 3IkhGyackK2ymlS3gRWe8BpkIHzr9jO6hOqIAX3DKPlIF87wUuubhKH4JDwkVaCIeVPi CSRcToYt+g1+MF3+bXS33HU1/rv14ZizO88NECnvLYIv8JWDd63ABmdgM6k3ufAyquYv iVL+1IKQhJtJ7L/HUe3ZImK1FHHo2MUm3d1CpFyctlgUylmANccmy/R6byer0maL5Zp8 rnznq/XfCV8GTFCvgS4lZvjFSW4enCdNUq4YtRDo/kO0YefBxBM9KoHcCYqnKjOviojv JC8A== X-Forwarded-Encrypted: i=1; AJvYcCWQKdKYXwLJbkEj8w4gy7YhuLCQK/RZrLBiYxWnB4AqrpsbfPTO6bP6gpKhU51RNz1iGhRpDR+tj5IWHpNafyiaIYMBzaZa X-Gm-Message-State: AOJu0YyOTi6w0/WfO94JxCjZG8qJnG5Z0LKVA54MEmoqif32cEg/I/PN Rh3X/4mL7qhX7iHH7h/0LYj/OzA9ZLPaFENkpzhtolk5HfAiQds2 X-Google-Smtp-Source: AGHT+IGucU9e6u2LQ+HBNngAU6cRcqKv1d01Xd4CYYi7t3yLVz54NP4Y42MX5JIm78r3DlxX0ikk4w== X-Received: by 2002:a17:907:7248:b0:a51:abb0:a8a2 with SMTP id ds8-20020a170907724800b00a51abb0a8a2mr8381554ejc.42.1712597179141; Mon, 08 Apr 2024 10:26:19 -0700 (PDT) Received: from localhost (fwdproxy-lla-003.fbsv.net. [2a03:2880:30ff:3::face:b00c]) by smtp.gmail.com with ESMTPSA id an3-20020a17090656c300b00a51cfd5c6ddsm2101455ejc.9.2024.04.08.10.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 10:26:18 -0700 (PDT) From: Breno Leitao To: kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 2/4] net: dql: Separate queue function responsibilities Date: Mon, 8 Apr 2024 10:25:54 -0700 Message-ID: <20240408172605.635508-3-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240408172605.635508-1-leitao@debian.org> References: <20240408172605.635508-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The dql_queued() function currently handles both queuing object counts and populating bitmaps for reporting stalls. This commit splits the bitmap population into a separate function, allowing for conditional invocation in scenarios where the feature is disabled. This refactor maintains functionality while improving code organization. Signed-off-by: Breno Leitao --- include/linux/dynamic_queue_limits.h | 44 ++++++++++++++++------------ 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/include/linux/dynamic_queue_limits.h b/include/linux/dynamic_queue_limits.h index ff9c65841ae8..9980df0b7247 100644 --- a/include/linux/dynamic_queue_limits.h +++ b/include/linux/dynamic_queue_limits.h @@ -83,28 +83,11 @@ struct dql { #define DQL_MAX_OBJECT (UINT_MAX / 16) #define DQL_MAX_LIMIT ((UINT_MAX / 2) - DQL_MAX_OBJECT) -/* - * Record number of objects queued. Assumes that caller has already checked - * availability in the queue with dql_avail. - */ -static inline void dql_queued(struct dql *dql, unsigned int count) +/* Populate the bitmap to be processed later in dql_check_stall() */ +static inline void dql_queue_stall(struct dql *dql) { unsigned long map, now, now_hi, i; - if (WARN_ON_ONCE(count > DQL_MAX_OBJECT)) - return; - - dql->last_obj_cnt = count; - - /* We want to force a write first, so that cpu do not attempt - * to get cache line containing last_obj_cnt, num_queued, adj_limit - * in Shared state, but directly does a Request For Ownership - * It is only a hint, we use barrier() only. - */ - barrier(); - - dql->num_queued += count; - now = jiffies; now_hi = now / BITS_PER_LONG; @@ -134,6 +117,29 @@ static inline void dql_queued(struct dql *dql, unsigned int count) WRITE_ONCE(DQL_HIST_ENT(dql, now_hi), map | BIT_MASK(now)); } +/* + * Record number of objects queued. Assumes that caller has already checked + * availability in the queue with dql_avail. + */ +static inline void dql_queued(struct dql *dql, unsigned int count) +{ + if (WARN_ON_ONCE(count > DQL_MAX_OBJECT)) + return; + + dql->last_obj_cnt = count; + + /* We want to force a write first, so that cpu do not attempt + * to get cache line containing last_obj_cnt, num_queued, adj_limit + * in Shared state, but directly does a Request For Ownership + * It is only a hint, we use barrier() only. + */ + barrier(); + + dql->num_queued += count; + + dql_queue_stall(dql); +} + /* Returns how many objects can be queued, < 0 indicates over limit. */ static inline int dql_avail(const struct dql *dql) { From patchwork Mon Apr 8 17:25:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13621429 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24B40144D25; Mon, 8 Apr 2024 17:26:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712597185; cv=none; b=bvhP6m1+1x8ysgDEOWg6uzXC33yahYlre2uXDnMLQBvNePMYuymtttb2CiwVH6Qw+YJp+xTFF3Jv+tdgEVHdU7WYjH6nIKmSmd7DMhK3wLt6M2D0/M//O1FBegIwH3QjqppyDhJRFwGc+E1Zp+AxZnZKXzWW6UitRs/H/7lRsHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712597185; c=relaxed/simple; bh=36sh5N/jvpjq6jwl9uDLoGCYQeODe9Y4/Xxq15VmGxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m2GRsqddBPi4f3Rdx+AeZ3SSuSFtNkPxWZbRS8D74txJXCdj8cgq24MzaIevbjn9kskR+/4UDglJBCKt5CeD9IXxop5C00/qVJYOh9jO9ht1OKNWDOD5lFRssGyukiEnS1lqwgHhNUczMNSQrYueYBrNyGqECuCj3hwFebgsmNQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-56e1f3462caso4842659a12.3; Mon, 08 Apr 2024 10:26:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712597182; x=1713201982; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xFdhNk5nsJDp0fP+o1jjxdXhOlujveYc4TGfWkAd6Tw=; b=NOQvsuMKInzZPBggOCNCNiRbhEAhM20w39RKeFYahie66OHMFUezMEDThYIEVNMfyS YcmYnpg3MIMh0UuI2reYvUfSKQ2/uDjIYeBbAxea6UERexeAeBt0X2VxYhx35IqDvK8o DhUza0mft4CpMR+an2MGu+BsknLvTuMpyq9EDw5AwDODYI1l/yD1AZmPiQk3oUaaks1k tpFQgMbtRrJieIJ6kHPgxHTM4HHSJ+3u1VLaLssmQskhWE0X+RNs9piS9ejammLMneAq UQdt8wYtr7NX50E4R1BXaizvpxrpcanUs7qPQYtzVThptMwOyQDIVzEBKYlH8xh4BPtr MdfQ== X-Forwarded-Encrypted: i=1; AJvYcCWh6YW9Ol+f5mMl7FC0YOeGMb0NrX/SZyzNslZVqtnvZn6DBIvPHwuxVncPfn8foDPuCg00bwqfSwrea4bkxipKYibbxqCP X-Gm-Message-State: AOJu0Yx7poLWq/xQGU5rfO1XIO8uWNzfv8CYf/BGV6FM2carAbliQIyw hNRED6xOnLohzUCiG996AkCRDXftmWjAqYu4PX+rcBlRS1DUtFAs X-Google-Smtp-Source: AGHT+IGWKqS0JTk/6lc5U817a4zP7AwTzEeUUquDYyq4dn2ZcNXJZoucuBugalkmndxMZJkGgavR4A== X-Received: by 2002:a17:907:7ea2:b0:a47:16d1:113f with SMTP id qb34-20020a1709077ea200b00a4716d1113fmr8250630ejc.47.1712597182466; Mon, 08 Apr 2024 10:26:22 -0700 (PDT) Received: from localhost (fwdproxy-lla-006.fbsv.net. [2a03:2880:30ff:6::face:b00c]) by smtp.gmail.com with ESMTPSA id gx26-20020a1709068a5a00b00a46b4c09670sm4695689ejc.131.2024.04.08.10.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 10:26:22 -0700 (PDT) From: Breno Leitao To: kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 3/4] net: dql: Optimize stall information population Date: Mon, 8 Apr 2024 10:25:55 -0700 Message-ID: <20240408172605.635508-4-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240408172605.635508-1-leitao@debian.org> References: <20240408172605.635508-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org When Dynamic Queue Limit (DQL) is set, it always populate stall information through dql_queue_stall(). However, this information is only necessary if a stall threshold is set, stored in struct dql->stall_thrs. dql_queue_stall() is cheap, but not free, since it does have memory barriers and so forth. Do not call dql_queue_stall() if there is no stall threshold set, and save some CPU cycles. Signed-off-by: Breno Leitao --- include/linux/dynamic_queue_limits.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/dynamic_queue_limits.h b/include/linux/dynamic_queue_limits.h index 9980df0b7247..869afb800ea1 100644 --- a/include/linux/dynamic_queue_limits.h +++ b/include/linux/dynamic_queue_limits.h @@ -137,7 +137,9 @@ static inline void dql_queued(struct dql *dql, unsigned int count) dql->num_queued += count; - dql_queue_stall(dql); + /* Only populate stall information if the threshold is set */ + if (READ_ONCE(dql->stall_thrs)) + dql_queue_stall(dql); } /* Returns how many objects can be queued, < 0 indicates over limit. */ From patchwork Mon Apr 8 17:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13621430 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B88921448E6; Mon, 8 Apr 2024 17:26:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712597189; cv=none; b=qURnUt6rqfVpzNCe06VLjdWtVeHlRISXbK9oyedjxsuaSp5fh7KGVYeAmbxCtRvoR72TtZP5a4ZKPTPkg5G/LlGbSSqOKqeICQ5Bun1WQQK0yCUeh5P9tV6ue26KPvHsgbKkYNgz5xuB4i49/zvI9DXex6UGSDMOBJ2Lnyrbp0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712597189; c=relaxed/simple; bh=BB6xdcqBBRM0M9Ry0QYPtGpccU8xNKpU0XluHoHcNZ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YL7Rcz+5CN2y3BYcnKcHJ7uqk0UDJHymuB9Y+smsR0+moKWXX+/D+xuChAu8b2mWacGP7WMrwzKRixlcGZ85c2i5mErhN9qEE4c/JfZjj35SOvdHzA39El/0frLu7xhVa32fWI74M7b2UL3+lcs4rz7hs0HpfQnEVTfcB8YY870= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-56e346224bdso2829746a12.1; Mon, 08 Apr 2024 10:26:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712597186; x=1713201986; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3GvozmrLkyQGC20P7bfv/jYd6/SqOcwnOpAWpJop5SM=; b=hR7YCcRgO5Daa4QdxJ788HQOrma8neTHfgybb/5ReWl0DtAkusRSm2P6ugAxy3cXkZ 9+V7dwgupJSMjxCw7zi1tlmkf5TlFofSit6O8IKkhGDZkPCSGWxhlYUsGet82e71xZj2 wrt3ZGp+3AFp8ZAV1znLwg3zJ88AW9hmsI/bvb2VSj1oNI8OK/r6I98+cpkF5mf+Ajj/ O5VfZOCbOGRFYMrGUaIlM3C4wZEbskJpgXFgWiqbLT8y/ycGc8MQgCtM3dEYmJnhLbe7 pw7cjBp8etPOtM17u8VlCcPSvXMTIWigJCz+U4M+fqAeBz4nb5V4GF0VapLrv3ReOMRQ a5eQ== X-Forwarded-Encrypted: i=1; AJvYcCXC1CrHOn4jPTj6hpyFqUjr6XnUqc9y1xJhrlVD10pebz1KzXX5eMUOlwpjJWrtdQZCVuV3XnrJTwgmAOwN0PgdvqRY2wc7 X-Gm-Message-State: AOJu0YzqTdtQ/Zd9euBL9DL3DkZ/mmHrp0DbYHNpu/aLv1ShF8+Nv7Y2 h/iDRUd5h1UMpQ4UP7thl3R893+24CTvnZnvtGwDLo+hZJN2Iy0K X-Google-Smtp-Source: AGHT+IFYUbY4WZ/0ZBQpTqBC7RgrqLxqyOCgqu18pEEv4vjQdy70C9zgi5iIe95NEx65Yrgy3HJQzw== X-Received: by 2002:a50:ccd6:0:b0:56c:5a49:730 with SMTP id b22-20020a50ccd6000000b0056c5a490730mr6862966edj.19.1712597185851; Mon, 08 Apr 2024 10:26:25 -0700 (PDT) Received: from localhost (fwdproxy-lla-120.fbsv.net. [2a03:2880:30ff:78::face:b00c]) by smtp.gmail.com with ESMTPSA id q18-20020aa7d452000000b0056e247de8e3sm4311465edr.1.2024.04.08.10.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 10:26:25 -0700 (PDT) From: Breno Leitao To: kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 4/4] net: dqs: make struct dql more cache efficient Date: Mon, 8 Apr 2024 10:25:56 -0700 Message-ID: <20240408172605.635508-5-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240408172605.635508-1-leitao@debian.org> References: <20240408172605.635508-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org With the previous change, struct dqs->stall_thrs will be in the hot path (at queue side), even if DQS is disabled. The other fields accessed in this function (last_obj_cnt and num_queued) are in the first cache line, let's move this field (stall_thrs) to the very first cache line, since there is a hole there. This does not change the structure size, since it moves an short (2 bytes) to 4-bytes whole in the first cache line. This is the new structure format now: struct dql { unsigned int num_queued; /* Total ever queued */ unsigned int last_obj_cnt; /* Count at last queuing */ ... short unsigned int stall_thrs; /* 12 2 */ /* XXX 2 bytes hole, try to pack */ ... /* --- cacheline 1 boundary (64 bytes) --- */ ... /* Longest stall detected, reported to user */ short unsigned int stall_max; /* 100 2 */ /* XXX 2 bytes hole, try to pack */ }; Suggested-by: Eric Dumazet Signed-off-by: Breno Leitao --- include/linux/dynamic_queue_limits.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/dynamic_queue_limits.h b/include/linux/dynamic_queue_limits.h index 869afb800ea1..281298e77a15 100644 --- a/include/linux/dynamic_queue_limits.h +++ b/include/linux/dynamic_queue_limits.h @@ -50,6 +50,9 @@ struct dql { unsigned int adj_limit; /* limit + num_completed */ unsigned int last_obj_cnt; /* Count at last queuing */ + /* Stall threshold (in jiffies), defined by user */ + unsigned short stall_thrs; + unsigned long history_head; /* top 58 bits of jiffies */ /* stall entries, a bit per entry */ unsigned long history[DQL_HIST_LEN]; @@ -71,8 +74,6 @@ struct dql { unsigned int min_limit; /* Minimum limit */ unsigned int slack_hold_time; /* Time to measure slack */ - /* Stall threshold (in jiffies), defined by user */ - unsigned short stall_thrs; /* Longest stall detected, reported to user */ unsigned short stall_max; unsigned long last_reap; /* Last reap (in jiffies) */