Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3192461imm; Sun, 3 Jun 2018 22:14:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLn9n5LpEfHr9BGAxd9EQHt488VKXwI/qhWuH2dA9rFrqBh0zXRmDwg5F74lZU7Lma3HuAz X-Received: by 2002:a63:8848:: with SMTP id l69-v6mr16452507pgd.149.1528089267430; Sun, 03 Jun 2018 22:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528089267; cv=none; d=google.com; s=arc-20160816; b=fc6lltetDCAdH3esw4q38nH0yjIk0UbKdsr2FVVTfmF5pkTFra2yCsqDzpUbjKqGVG lsW44VtSftmCrZ/7/AMQM2t37TraGDK3QFli30x5ssIyLkudCBftHCfe6S0Dy0CjYGHZ btOVByvAqwJwh4kPijwKiI4wSqadVuJzEviGGooYhfpBOA+8W0eGydy0DIr4oDAHDy95 Jl38xGX2kORnOj8/QP86n4Wr1l8mW8/ra61ks3/HGTolx6NPLjJcftCvQWu6f2fa8k+z 14/1KmM4j2PYQUqnRg1m9z64w8Ro8Exv9gureKqhUX2NRUfCc8iDRLFlv6sWV4GTH/BW mHhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=LiVtjYLUzescj0KnCWW3ClVKjgYWFJ/118ntBqdMolk=; b=euhg0axzNaePmb8Mh/U6XFUOd4WKBjGPY1I7l7+O6veGEfFHKFYFQrj1K69g36zO4y mWSfCXcCFBKGUKs5r1sCeM5jAA5TYAtcqJFscLYWTDMv5vuQNJVwknKr6iiOp0hewFeu Fx0BRY94ZqmlRxTQRvmahUH5KiebRQNyNz0cJyvWTGLubC4jEXqTHBr+sW6ZWnIiaWsT nNCDk1hm8Z4im0nTOBRHhRx/JQ4X2yz4Xe4QF/Hqk+UtWg8hdnkUefaGl1atqCT1yEm9 17nMazC8W9QlgmZSqTZ9qpALV4f/B36JFhqQYy2NuUQMx+jICk5T4n2lUmJIJS2TPcOY yivQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=qE8ryQoj; 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=NONE dis=NONE) header.from=joelfernandes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e5-v6si35790457pgs.317.2018.06.03.22.14.00; Sun, 03 Jun 2018 22:14:27 -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=@joelfernandes.org header.s=google header.b=qE8ryQoj; 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=NONE dis=NONE) header.from=joelfernandes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751786AbeFDFNZ (ORCPT + 99 others); Mon, 4 Jun 2018 01:13:25 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:45254 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751061AbeFDFNY (ORCPT ); Mon, 4 Jun 2018 01:13:24 -0400 Received: by mail-pl0-f65.google.com with SMTP id c23-v6so7639945plz.12 for ; Sun, 03 Jun 2018 22:13:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=LiVtjYLUzescj0KnCWW3ClVKjgYWFJ/118ntBqdMolk=; b=qE8ryQojBHcQt8ooEIwNQs3ttnA7GaMPbxSzIy+TDImICX9bMWZe0nraqIJqDRx4Za SL24pX33y0pKP0nntupEz+9UAkAZ45zbZPbXD9EJs0CsKGKS+MYnByahgsRf7afnqtoD Mrr1W5oTXN325GzuCt7iXo1uDK+iAldxNZEHE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=LiVtjYLUzescj0KnCWW3ClVKjgYWFJ/118ntBqdMolk=; b=ada9Mk/COC4adtIyFFJ7btosld0GcIIKLF/3ZB/JECF5hQiMwOmPosMX+ij59NOeSy CLm5Gb8RdVC4rGjMkhc6CqAxQAawDOhda+dH3THPro2xxstOcAa6Xhn5ulvfcGVhVgT3 Dg98DPAngquDEgeSjrhtaAJqyAkOWgfgHqcSobqzSkz1GFVszhBnBJifjQWrg+I+otVn NwYqJ6mc36Q4d587qMN0ykTBxyvmxv7EJLxOmSbS2cVN5gAY9pgmcos2HkwVexmph7Rp 9JGP4/t9sNZSIRrjYHBaE8UfweP30DxOvDr0F1p9VsGbsz6O8Gi8aKbzbSdT9to6WRYk NY/w== X-Gm-Message-State: ALKqPwdwItB4g4hfs3ZtEXJmBTX03+jEyQIooAAptdmiHSySvzWmae4l iMPSvdMgjsc/Wg8OehjB61S9TQ== X-Received: by 2002:a17:902:bd93:: with SMTP id q19-v6mr20152697pls.342.1528089203463; Sun, 03 Jun 2018 22:13:23 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id q9-v6sm9476436pgv.84.2018.06.03.22.13.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Jun 2018 22:13:22 -0700 (PDT) Date: Sun, 3 Jun 2018 22:13:22 -0700 From: Joel Fernandes To: "Paul E. McKenney" Cc: Byungchul Park , jiangshanlai@gmail.com, Paul McKenney , josh@joshtriplett.org, rostedt@goodmis.org, peterz@infradead.org, Mathieu Desnoyers , linux-kernel@vger.kernel.org, kernel-team@lge.com, kernel-team@android.com, Davidlohr Bueso Subject: Testing RCU boosting with rcutorture Message-ID: <20180604051322.GA21496@joelaf.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, I was testing RCU boosting behavior with rcutorture on rcu/dev and I had some issues getting it to fail when no RCU boost is done (CONFIG_RCU_BOOST is disabled and rcutorture is forced to test it using test_boost parameter). It appears I need to disable RT throttling so that the readers can get starved by the RT thread. I also noticed some problems in rcutorture where we are not checking for failure correctly. Below is an RFC patch fixing these issues, could you let me know your thoughts about it? Thanks a lot, - Joel ---8<----------------------- From: "Joel Fernandes (Google)" Date: Sun, 3 Jun 2018 21:30:26 -0700 Subject: [RFC] rcutorture: Make boost test more robust Currently, with RCU_BOOST disabled, I get no failures when forcing rcutorture to test RCU boost priority inversion. The reason seems to be that we don't check for failures if the callback never ran at all for the duration of the boost-test loop. Further, the 'rtb' and 'rtbf' counters seem to be used inconsistently. 'rtb' is incremented at the start of each test and 'rtbf' is incremented per-cpu on each failure of call_rcu. So its possible 'rtbf' > 'rtb'. To test the boost with rcutorture, I did following on a 4-CPU x86 machine: # Disable RT throttling echo 1000000 > /proc/sys/kernel/sched_rt_period_us echo 1000000 > /proc/sys/kernel/sched_rt_runtime_us modprobe rcutorture test_boost=2 sleep 20 rmmod rcutorture With patch: rtbf: 8 rtb: 12 Without patch: rtbf: 0 rtb: 2 In summary this patch: - Increments failed and total test counters once per boost-test. - Checks for failure cases correctly. Signed-off-by: Joel Fernandes (Google) --- kernel/rcu/rcutorture.c | 45 +++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 773d6f1b4abf..1d26f9c27d36 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -769,6 +769,18 @@ static void rcu_torture_boost_cb(struct rcu_head *head) smp_store_release(&rbip->inflight, 0); } +static bool rcu_torture_boost_failed(unsigned long start, unsigned long end) +{ + if (end - start > test_boost_duration * HZ - HZ / 2) { + VERBOSE_TOROUT_STRING("rcu_torture_boost boosting failed"); + n_rcu_torture_boost_failure++; + + return true; /* failed */ + } + + return false; /* passed */ +} + static int rcu_torture_boost(void *arg) { unsigned long call_rcu_time; @@ -789,6 +801,21 @@ static int rcu_torture_boost(void *arg) init_rcu_head_on_stack(&rbi.rcu); /* Each pass through the following loop does one boost-test cycle. */ do { + /* Track if the test failed already in this test interval? */ + bool failed = false; + + /* Increment n_rcu_torture_boosts once per boost-test */ + while (!kthread_should_stop()) { + if (mutex_trylock(&boost_mutex)) { + n_rcu_torture_boosts++; + mutex_unlock(&boost_mutex); + break; + } + schedule_timeout_uninterruptible(1); + } + if (kthread_should_stop()) + goto checkwait; + /* Wait for the next test interval. */ oldstarttime = boost_starttime; while (ULONG_CMP_LT(jiffies, oldstarttime)) { @@ -807,11 +834,10 @@ static int rcu_torture_boost(void *arg) /* RCU core before ->inflight = 1. */ smp_store_release(&rbi.inflight, 1); call_rcu(&rbi.rcu, rcu_torture_boost_cb); - if (jiffies - call_rcu_time > - test_boost_duration * HZ - HZ / 2) { - VERBOSE_TOROUT_STRING("rcu_torture_boost boosting failed"); - n_rcu_torture_boost_failure++; - } + /* Check if the boost test failed */ + failed = failed || + rcu_torture_boost_failed(call_rcu_time, + jiffies); call_rcu_time = jiffies; } stutter_wait("rcu_torture_boost"); @@ -819,6 +845,14 @@ static int rcu_torture_boost(void *arg) goto checkwait; } + /* + * If boost never happened, then inflight will always be 1, in + * this case the boost check would never happen in the above + * loop so do another one here. + */ + if (!failed && smp_load_acquire(&rbi.inflight)) + rcu_torture_boost_failed(call_rcu_time, jiffies); + /* * Set the start time of the next test interval. * Yes, this is vulnerable to long delays, but such @@ -831,7 +865,6 @@ static int rcu_torture_boost(void *arg) if (mutex_trylock(&boost_mutex)) { boost_starttime = jiffies + test_boost_interval * HZ; - n_rcu_torture_boosts++; mutex_unlock(&boost_mutex); break; } -- 2.17.1.1185.g55be947832-goog