From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933794AbdKGVH5 (ORCPT ); Tue, 7 Nov 2017 16:07:57 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:34409 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753561AbdKGVH4 (ORCPT ); Tue, 7 Nov 2017 16:07:56 -0500 Date: Tue, 7 Nov 2017 22:07:48 +0100 From: Peter Zijlstra To: Jeremy Linton Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, paulmck@linux.vnet.ibm.com, dave@stgolabs.net Subject: Re: [PATCH] locktorture: Fix Oops when reader/writer count is 0 Message-ID: <20171107210748.GR3165@worktop.lehotels.local> References: <20171010155248.11602-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 07, 2017 at 02:01:58PM -0600, Jeremy Linton wrote: > Hi, > > On 10/10/2017 10:52 AM, Jeremy Linton wrote: > >If nwriters_stress=0 is passed to the lock torture test > >it will panic in: > > Ping? > > Has anyone had a chance to look at this? Helps if you Cc the people actually working on this stuff of course... > > > > >Internal error: Oops: 96000005 [#1] SMP > >... > >[] __torture_print_stats+0x2c/0x1c8 [locktorture] > >[] lock_torture_stats_print+0x74/0x120 [locktorture] > >[] lock_torture_stats+0x40/0xa8 [locktorture] > >[] kthread+0x108/0x138 > >[] ret_from_fork+0x10/0x18 > > > >This is caused by the deference to a null statp. Fix that by > >checking the n_stress for non zero count before referencing statp. > > > >Signed-off-by: Jeremy Linton > >--- > > kernel/locking/locktorture.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > >diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c > >index f24582d4dad3..8229ba7147e5 100644 > >--- a/kernel/locking/locktorture.c > >+++ b/kernel/locking/locktorture.c > >@@ -716,10 +716,14 @@ static void __torture_print_stats(char *page, > > bool fail = 0; > > int i, n_stress; > > long max = 0; > >- long min = statp[0].n_lock_acquired; > >+ long min = 0; > > long long sum = 0; > > n_stress = write ? cxt.nrealwriters_stress : cxt.nrealreaders_stress; > >+ > >+ if (n_stress) > >+ min = statp[0].n_lock_acquired; > >+ > > for (i = 0; i < n_stress; i++) { > > if (statp[i].n_lock_fail) > > fail = true; > > >