Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755058AbdLFK7q (ORCPT ); Wed, 6 Dec 2017 05:59:46 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2214 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755029AbdLFK7n (ORCPT ); Wed, 6 Dec 2017 05:59:43 -0500 From: To: CC: , , Subject: [PATCH 1/2] rcutorture: Add usage warnings for parameters gp_normal and gp_exp Date: Wed, 6 Dec 2017 18:51:07 +0800 Message-ID: <1512557468-52633-2-git-send-email-lianglihao@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1512557468-52633-1-git-send-email-lianglihao@huawei.com> References: <1512557468-52633-1-git-send-email-lianglihao@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1575 Lines: 42 From: Lihao Liang In rcu_torture_fakewriter(), when param gp_normal is equal to gp_exp (even when they are false), both cur_ops->sync() and cur_ops->exp_sync() may be invoked. This commit checks that if any of them is NULL, it will print out a warning message. It also emits a warning if gp_normal is true but cur_ops->sync() is NULL. Signed-off-by: Lihao Liang --- I think the last else-if block is redundant and I choose to include it for completeness. In addition, it may be better to have more informative warning messages for the new if-else blocks. Feel free to revise them. kernel/rcu/rcutorture.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index d1b64dc..d2abebd 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -937,6 +937,16 @@ rcu_torture_writer(void *arg) synctype[nsynctypes++] = RTWS_SYNC; else if (gp_sync && !cur_ops->sync) pr_alert("%s: gp_sync without primitives.\n", __func__); + if (gp_normal == gp_exp) { + if (!cur_ops->sync) + pr_alert("%s: gp_sync without primitives.\n", __func__); + if (!cur_ops->exp_sync) + pr_alert("%s: gp_exp without primitives.\n", __func__); + } else if (gp_normal && !cur_ops->sync) { + pr_alert("%s: gp_sync without primitives.\n", __func__); + } else if (gp_exp && !cur_ops->exp_sync) { + pr_alert("%s: gp_exp without primitives.\n", __func__); + } if (WARN_ONCE(nsynctypes == 0, "rcu_torture_writer: No update-side primitives.\n")) { /* -- 2.7.4