Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp471845imm; Wed, 18 Jul 2018 05:32:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcHUUBbnQd5Z+6W0J1MynzxKp6O8P/0icV7y7hx6MBCQXCjD2dJiirNnssXFY0xcw/wmKCE X-Received: by 2002:a62:fb05:: with SMTP id x5-v6mr5072754pfm.210.1531917130028; Wed, 18 Jul 2018 05:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531917130; cv=none; d=google.com; s=arc-20160816; b=JzR8aWRMdyCmeB+QLGG17tNmYHBmnq9seAShdIYjujudRpU8QNwKRVKFIng/o4Noe8 YXguITjj8C50XPvRU5BQmwerHMZ56IBst/20N1cJhmIqevQgosdaHY4rrkoALwYZmC1i aLmWjsVUnVWhDQbrps7cP/elMOD40RQATJFsrpF/Zww420t1dMlx9Onr6ZJadXgz0wrE ewnxNdFwNSX74EfyEkBnpWt26Hpky0rHdry7KAczExFeeXce+bcs1oThAYJnb10xtqnr LiMecAKuSYOutHK6yb3xOorjtvlsRhdPQ5T591WZ1Vx2ePU4bJkxa08TqvY22oMa/YSP XSVg== 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=KZizVV2HgS4fy3wOyADxwdBHTyTCh1DrkWivdfUFHCE=; b=McEmXHV6cSABlVBZhhNdfRs5J6RKXdw/wZRSC2pkCs6FU98fq2clG932tasAIFnYEs i/VfZVmO72luUaQIDqijKdQ9xXPTp0GIg8c6Bd+OYqq5dPM433qI6VZyeQgYkB5nxFY2 cDdz9O6Rd9rRh2oF6ZPFcavTpi1DCpiweJ8fpLct+o57zYOoOTiDnyWHW0npnfuKcrSV 2J0Cp4LT2f8gFm+HkGnHESnyvOCvTeijpCMen2W4e5y3OqA74oAgZg3IeQa6Rb5j9T5n Jk6s3z4rdY6+qB2kGfeHpm5+Gx0Z9xmA4i0naZ4mK0bGSfB9PGGp4gD3GpSKSFsQH/LE TjrA== 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 15-v6si3263704pgu.205.2018.07.18.05.31.55; Wed, 18 Jul 2018 05:32:09 -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 S1731161AbeGRNJG (ORCPT + 99 others); Wed, 18 Jul 2018 09:09:06 -0400 Received: from ozlabs.org ([203.11.71.1]:43415 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730511AbeGRNJG (ORCPT ); Wed, 18 Jul 2018 09:09:06 -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 41VxMm1PmGz9s0w; Wed, 18 Jul 2018 22:31:16 +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> <87va9dyl8y.fsf@concordia.ellerman.id.au> Date: Wed, 18 Jul 2018 22:31:14 +1000 Message-ID: <874lgwpvxp.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 Tue, Jul 17, 2018 at 7:45 AM Michael Ellerman wrote: >> >> >> 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 > > Oh, see that's the difference. > > You're running in a non-root cgroup, I think. I'm not much of a cgroup expert, but yeah I think so: # cat /proc/self/cgroup 7:cpuset:/ 6:cpu,cpuacct:/user.slice 5:memory:/user.slice ... I guess I need to boot with init=/bin/sh. > That also means that your scheduler overhead has way more spinlocks, > and in particular, you have that > > raw_spinlock_t *cpu_lock = per_cpu_ptr(&cgroup_rstat_cpu_lock, cpu); > .. > raw_spin_lock_irqsave(cpu_lock, flags); > > there too. > > So you have at least twice the spinlocks that my case had, and yes, > the costs are way more spread out because your case has all that > cgroup accounting too. Yeah OK. And our locks are known to be more expensive generally, so that and the cgroups seems like it accounts for most of the difference vs x86. > That said, I don't understand the powerpc memory ordering. I thought > the rules were "isync on lock, lwsync on unlock". > > That's what the AIX docs imply, at least. > > In particular, I find: > > "isync is not a memory barrier instruction, but the > load-compare-conditional branch-isync sequence can provide this > ordering property" > > so why are you doing "sync/lwsync", when it sounds like "isync/lwsync" > (for lock/unlock) is the right thing and would already give memory > barrier semantics? I think everyone else in the thread answered this already, and better than I could. Our options are sync/lwsync or lwsync/sync. I've been testing lwsync/sync, because then we could also remove the conditional sync we have in unlock (when there were IO accesses inside the lock). These days you can download the ISA [PDF], with no registration or anything required, here's a direct link: https://ibm.ent.box.com/index.php?rm=box_download_shared_file&shared_name=1hzcwkwf8rbju5h9iyf44wm94amnlcrv&file_id=f_253346319281 That has some docs on locking in Book3 appendix B.2 (page 915). It doesn't really have that much detail, but it does talk a bit about using lwsync vs isync. cheers