Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3621167imm; Tue, 17 Jul 2018 07:46:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfkfTS1m9/0C28/iqjjCkNDC6/nUIuTAAThQ5bIoo8GgAJjbpsLsDLIQI1GtSSxd5hKyS9V X-Received: by 2002:a62:3b89:: with SMTP id w9-v6mr1007486pfj.80.1531838772507; Tue, 17 Jul 2018 07:46:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531838772; cv=none; d=google.com; s=arc-20160816; b=v/A4t9OfIFqPMpLkz296Wc4cWXGeKNvVSqBJ8GrQx6fvsVbw1Rg2WjcwbpeHK1o+sW j7NTQicmgFFT7J338IxqK8fWKc2nTKsNTMpVCunrWDyq3I+UmoEo1lxcMdxkVCCqWtDH o6yQT0Zs5A1MGuQfjpHV58wDiAsyN3Ed8skfIR6NmjAzaOTgWMIuGnQhhDTMki4fBhYi 6MQ5QWTWEYZgkq2zSwjc+q+9ziDvj0kzBbn+ZrJ40EcGL4nDAWR4Eue+xHQw8xLmVw6f ArzovCo8LRc2UGmY5itmIm0iu4O4bBKwM/pvZQe3M9NGBg+Yimkssc/JT55hTSRwl4CX Je+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:arc-authentication-results; bh=HwToTzC4+3r/M3eypr9VJbfR0zFsQgbreK3Q4Qw2BpU=; b=gs08G4Tmck2QPFNJMwdIgGP0Dl0NCp/iXdmk4ZP3Wpy+HyLvHUV8RyieGByezhy3LO rdFW6hMO9dKlpCduMRr/wWH3aVz0gL/Jqssl1czhOD52ZQ1DNFHi3G3RVx+qSpuyLgWj mmw8WndY7dKJR6aKuWzkqOykH80g44QqzMz4iXkwCGnDRikzJmjiF3YMM9Z0NPx261iL /v95tufgjOc8We76ylpFYjUlkl+Caq0nKSsUeFSFuCLyjzm26TlqVWbFXDW8JsA0UvBS IfLe5aiZhpB0XyN5sgoaH5/Ry/c+/yi4dtn/X6ZBxofiUlva5jMJApswFCupVSbIV0n8 6Pvw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u11-v6si1241911plm.143.2018.07.17.07.45.57; Tue, 17 Jul 2018 07:46:12 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731669AbeGQPSO (ORCPT + 99 others); Tue, 17 Jul 2018 11:18:14 -0400 Received: from ozlabs.org ([203.11.71.1]:44317 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729673AbeGQPSO (ORCPT ); Tue, 17 Jul 2018 11:18:14 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 41VNNf18D3z9s0n; Wed, 18 Jul 2018 00:45:06 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au From: Michael Ellerman To: Linus Torvalds Cc: Peter Zijlstra , Paul McKenney , Alan Stern , andrea.parri@amarulasolutions.com, Will Deacon , Akira Yokosawa , Boqun Feng , Daniel Lustig , David Howells , Jade Alglave , Luc Maranget , Nick Piggin , Linux Kernel Mailing List Subject: Re: [PATCH v2] tools/memory-model: Add extra ordering for locks and remove it for ordinary release/acquire In-Reply-To: References: <20180712134821.GT2494@hirez.programming.kicks-ass.net> <20180712172838.GU3593@linux.vnet.ibm.com> <20180712180511.GP2476@hirez.programming.kicks-ass.net> <20180713110851.GY2494@hirez.programming.kicks-ass.net> <87tvp3xonl.fsf@concordia.ellerman.id.au> <20180713164239.GZ2494@hirez.programming.kicks-ass.net> <87601fz1kc.fsf@concordia.ellerman.id.au> Date: Wed, 18 Jul 2018 00:45:01 +1000 Message-ID: <87va9dyl8y.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Linus Torvalds writes: > On Mon, Jul 16, 2018 at 7:40 AM Michael Ellerman wrote: ... >> I guess arguably it's not a very macro benchmark, but we have a >> context_switch benchmark in the tree[1] which we often use to tune >> things, and it degrades badly. It just spins up two threads and has them >> ping-pong using yield. > > I hacked that up to run on x86, and it only is about 5% locking > overhead in my profiles. It's about 18% __switch_to, and a lot of > system call entry/exit, but not a lot of locking. Interesting. I don't see anything as high as 18%, it's more spread out: 7.81% context_switch [kernel.kallsyms] [k] cgroup_rstat_updated 7.60% context_switch [kernel.kallsyms] [k] system_call_exit 5.91% context_switch [kernel.kallsyms] [k] __switch_to 5.69% context_switch [kernel.kallsyms] [k] __sched_text_start 5.61% context_switch [kernel.kallsyms] [k] _raw_spin_lock 4.15% context_switch [kernel.kallsyms] [k] system_call 3.76% context_switch [kernel.kallsyms] [k] finish_task_switch And it doesn't change much before/after the spinlock change. (I should work out how to turn that cgroup stuff off.) I tried uninlining spin_unlock() and that makes it a bit clearer. Before: 9.67% context_switch [kernel.kallsyms] [k] _raw_spin_lock 7.74% context_switch [kernel.kallsyms] [k] cgroup_rstat_updated 7.39% context_switch [kernel.kallsyms] [k] system_call_exit 5.84% context_switch [kernel.kallsyms] [k] __sched_text_start 4.83% context_switch [kernel.kallsyms] [k] __switch_to 4.08% context_switch [kernel.kallsyms] [k] system_call 1.24% context_switch [kernel.kallsyms] [k] arch_spin_unlock <-- After: 8.69% context_switch [kernel.kallsyms] [k] _raw_spin_lock 7.01% context_switch [kernel.kallsyms] [k] cgroup_rstat_updated 6.76% context_switch [kernel.kallsyms] [k] system_call_exit 5.59% context_switch [kernel.kallsyms] [k] arch_spin_unlock <-- 5.10% context_switch [kernel.kallsyms] [k] __sched_text_start 4.36% context_switch [kernel.kallsyms] [k] __switch_to 3.80% context_switch [kernel.kallsyms] [k] system_call I was worried spectre/meltdown mitigations might be confusing things, but not really, updated numbers with them off are higher but the delta is about the same in percentage terms: | lwsync/lwsync | lwsync/sync | Change | Change % +---------------+-------------+------------+---------- Average | 47,938,888 | 43,655,184 | -4,283,703 | -9.00% > I'm actually surprised it is even that much locking, since it seems to > be single-cpu, so there should be no contention and the lock (which > seems to be > > rq = this_rq(); > rq_lock(rq, &rf); > > in do_sched_yield()) should stay local to the cpu. > > And for you the locking is apparently even _more_ noticeable. > But yes, a 10% regression on that context switch thing is huge. You > shouldn't do ping-pong stuff, but people kind of do. Yeah. There also seem to be folks who have optimised the rest of their stack pretty hard, and therefore care about context switch performance because it's pure overhead and they're searching for every cycle. So although this test is not a real workload it's a proxy for something people do complain to us about. cheers