Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1497296lqe; Mon, 8 Apr 2024 10:26:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWPYRq6PYz37DzsvEuLKQpfQlrdnBy1XY/OBaLsLGWsMNe5mzfuBTCgzm3uVyZwRosM/ph1rT1Uyl+prolQR2T46a8w/xE4FipsuRBzYA== X-Google-Smtp-Source: AGHT+IEdUJM91tHzRcqQM7oP105mW2cYg8nHEjqB9L7YQ5oLngEvxJ9dym7lIBcZyh+aLVkkGwh+ X-Received: by 2002:a05:651c:1545:b0:2d8:394c:6e7e with SMTP id y5-20020a05651c154500b002d8394c6e7emr7437389ljp.15.1712597198758; Mon, 08 Apr 2024 10:26:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712597198; cv=pass; d=google.com; s=arc-20160816; b=Yq4Ns8Qpi9OuLrGoG4EtRKJsVrJP7AqzUhDC6+aHPWYad1g6cvv+/NcjEUQzM3j+aZ ls2ziOKY+qz3aSLdo115azigS8WywBdOtVo5Ov0mk35cVsM0PTiJb6gjNSDdeRnxGMjb GiWfG5gvrCfd46otQ5BYM2JM0s6p4/4FoILCt9ZrXuOY03Al68dOe1lYd2AYbVkI7ly9 t/EcAJvTulAGNKZTsyqo60ytQnZKxvt3cZsd1aOO19L+iB4sHha4h6EIcJ0kSQKx0U4a f2f52QeDiJCwrvpXIZZjJsanIQB1Et2wAFtZrRbYPvf1PsQxZu9bkkAvAk+IgIc2sD4V RfFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=G8m6X0YutT7uWn1TO1PGQ+ufRs6DUh470J81GT16/S0=; fh=fEoMjtl167jmUVXP9S6+thtIO9d09lss2uuzi0H4PHo=; b=UmL07ZSaY56wjyIy2Xp3oiWDo0P2GE9n6GAoSl32CWGaHQwreBIQRVe515uPjmeb40 YuTA4j2cP0EIEH3KrTO+hTeZeypWleUZr950U9bic3ElfnWJQvA2Tqum4mAY86Tmj3Nt bvrY+HeThGS6kWTKOWKpnnfcoDKZBzmr6mIpLU3t6AELWWiayJpmP7WMJNELXn5U3v4T SsQ79N2S88MT8Up2+H3akJNPVvx8zSOA16+hftOqV1tPPDBQCyfrFjIA2mJ5A+G45h1n SOdC8hsFtwFuYh1FNeoM0zWUV5wKWwJ4x72seNe0dyazGuTtkXNP6N57E9uYUIsLh1V8 2w6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-135746-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135746-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x2-20020a50ba82000000b0056e47321892si2619963ede.374.2024.04.08.10.26.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 10:26:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135746-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-135746-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135746-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 778B91F27774 for ; Mon, 8 Apr 2024 17:26:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB2E81448C1; Mon, 8 Apr 2024 17:26:19 +0000 (UTC) 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-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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; -- 2.43.0