Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5581255imm; Wed, 12 Sep 2018 08:05:19 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaXW2ZFtchmgE5AFtrsrQTbeZrglrEy62DkNbiiREZmdsBN0kIQexPotwHp3G3lqdcw2tfK X-Received: by 2002:a62:2285:: with SMTP id p5-v6mr2867627pfj.53.1536764718843; Wed, 12 Sep 2018 08:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536764718; cv=none; d=google.com; s=arc-20160816; b=JSGIbOAwLOQCV6mtwgwSW4QrEC5tb2rB1+iUCyFPHsxPxFw3qbGpXtgC0eU3ljcdYc rIXLdKhwO9641NgVFGnZEOTkzLUGicewxr78MM26Aw4/5V0qZmsPo2Z9bU4EfJIvmNo7 vMMcfzs6+sNvxTQdJEdRYWKBsuf+JglKXHUd7A6y847ZygAPjTNjNNyyS5ubVuoLOLTl ozlVxFUVNHWeYqbLJarJqws1bQN4knaFDWM/WKMDxfrbReUrvdVTG3Bta2RyKCJdURW0 iDRG5lXZ6aGcwI+WpoeOWr6ccwkyDNwXEGVKNnVhbPW+vpi4bD0drB1lL6IncM3iu9t/ mhag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=EfmF5rnZsA8UZXxcsYOpARFBCLiQHgR/1Y1491vQUYQ=; b=XdceIGvXJFudmYgspFRfh/WruBlTRnSlscoiR3w7/6DNxb8Uqcfh39TeQrA1PFAWxh nSliZnLpShSIfKLybNf4DU2GcuXYHe2yo9UMEag86I8FOJ5jux/wauzSakx7VPEWAipd +xBHpqvQ/G+eXSZviCHy57Tilf2DDVX6OeW8kRl/3Q/Kgvgx6pD03//2XXmSg9VIFInl 85YpazokPN4bhFD1Ln7bmQwO5xspGDVoVmXX9wz0i0tvybuE3hEuUGKHRJcTIXKCEmsS ofh5QTc+Kg0vqz/yw7sl/scHA516uHFCYifYcfstyXPj1VJtA94T724Ab0x1Ux3f5PCz sLxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bFVvN3sT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si1157560pfx.293.2018.09.12.08.05.00; Wed, 12 Sep 2018 08:05:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bFVvN3sT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728253AbeILUJa (ORCPT + 99 others); Wed, 12 Sep 2018 16:09:30 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:39179 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727804AbeILUJa (ORCPT ); Wed, 12 Sep 2018 16:09:30 -0400 Received: by mail-lf1-f67.google.com with SMTP id v77-v6so2000172lfa.6; Wed, 12 Sep 2018 08:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=EfmF5rnZsA8UZXxcsYOpARFBCLiQHgR/1Y1491vQUYQ=; b=bFVvN3sT786agduS8FqJdpkQcxxMsiUdiS1ElCP2sOnyQviYNKqR4HyVG1rJNItFxW QMx975k8srG+VnhpqLsYa7nDhAMw+DvR6jfPEsROzFtnSNyKgFsB6kjm6HnJPCnknn0r qim4GcpN7grODDaKyBEdr5jhd2tokdK+LVMWzqqkhzcYnhPM1mkcLwpRLA/3KdvmWe7z hAxR2U0AT2SUwcx1rbh5JWvttlzQ0Rt0lp7VnQLRskskDWPrY/o/pQjk3BS3ynKJ/AMP 2khRbuJXKERFoTICQlVsQQngIicsRgNsbRzC4b6XlQUUw6O91a8fmC4By/C7zW+Fo/xY sJoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=EfmF5rnZsA8UZXxcsYOpARFBCLiQHgR/1Y1491vQUYQ=; b=KGmtlzkOuuBi30HrJYTOaM4t7sCfL4QXQG6xrqZOKXGfJ0hoXV/bjKE/lfSjEUoxYo Pe+bhSkwPW6o3f8ZBNEMw06EGxTeO5Vlt0OQGQco2md6LSl9Dt2cDp6zjk6BIYyTt38k 8DQTdNXh0I6z1npWxu7LqvmhATGt6RMNAUtVdeCg/jt8qo2yFiVq1b7a+d5/7yVbg6z7 scUHyeG+bOLoWiPqu8I3arFt/omMD+pGdYTkO68I9qCD1UE72ON0WOhRKvqpmco4eh7W soyGnOBTs0lE690PN2pEaGKna0+GpBWeaJnTB4NyqJxhYebin5GsxY08OsFOKzJaLUQy gKLQ== X-Gm-Message-State: APzg51CFNoQb6jgfoBJz+E0g/wFckMCbk74zyjMV967V/F5XJaWNZsBt RykXELnPUpYpXXkBbf0Xtq51FPjUmII= X-Received: by 2002:a19:3855:: with SMTP id d21-v6mr1827010lfj.24.1536764672832; Wed, 12 Sep 2018 08:04:32 -0700 (PDT) Received: from ?IPv6:2001:14bb:73:639a:d135:7d7c:caf7:1c82? (drqv51zl1s10p1948tk-4.rev.dnainternet.fi. [2001:14bb:73:639a:d135:7d7c:caf7:1c82]) by smtp.gmail.com with ESMTPSA id u2-v6sm215769ljg.55.2018.09.12.08.04.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 08:04:32 -0700 (PDT) Subject: Re: [PATCH v2] ethernet: hnae: drop adhoc assert() macros To: David Miller Cc: igor.stoppa@huawei.com, huangdaode@hisilicon.com, yisen.zhuang@huawei.com, salil.mehta@huawei.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180908150142.27976-1-igor.stoppa@huawei.com> <20180911.230716.1048852895308106303.davem@davemloft.net> From: Igor Stoppa Message-ID: <2f439541-154f-1f17-180e-db0d8f95e010@gmail.com> Date: Wed, 12 Sep 2018 18:04:30 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180911.230716.1048852895308106303.davem@davemloft.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/09/18 09:07, David Miller wrote: > From: Igor Stoppa > Date: Sat, 8 Sep 2018 18:01:42 +0300 > >> Replace assert() with a less misleading test_condition() using WARN() >> Drop one check which had bitrotted and didn't compile anymore. >> >> Signed-off-by: Igor Stoppa > > I'm still kind of not happy about this. > > Make the driver use kernel interfaces like WARN_ON_ONCE() > etc. directly instead of defining alias CPP macros private to the > driver. > > If it needs to be conditional upon DEBUG, we have pr_debug() and > the likes as well. WARN_ON_ONCE() will display the error message only once, but from its implementation it looks like it will evaluate the condition anyways, every time, unless the compiler can do some magic and somehow know that the condition was true already onece (/include/asm-generic/bug.h:146) pr_debug() otoh, will print or not print, depending on CONFIG_DYNAMIC_DEBUG being set or not (/include/linux/printk.h:399) but the logic we are trying to clean up here seems a bit different: if (in_debug_mode && error_condition_is_verified) generate_warning() Which, I guess, is meant to completely remove *any* test outside of debug mode. That is why I used the test_condition() macro, instead of using directly WARN_ON_ONCE(). Admittedly, it probably would have been better to depend on CONFIG_DYNAMIC_DEBUG. Neither using WARN_ON_ONCE(), nor pr_debug() seem to replicate the initial behavior of the code that is currently in the tree, with assert(). How would you suggest that I keep the same behavior, without the helper macro? I am probably missing it, but I do not see some facility that would support the double condition I described above. -- thanks, igor