Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp771620imm; Fri, 10 Aug 2018 22:58:13 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzkCqO3yewNs0PlqzIgLjU6110wYMAnnQsT20hJdg8Me/Od2mdfpLfdK7y/2TEuT6zCgWuJ X-Received: by 2002:a17:902:6b44:: with SMTP id g4-v6mr8717820plt.50.1533967093492; Fri, 10 Aug 2018 22:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533967093; cv=none; d=google.com; s=arc-20160816; b=pI1ffQ4mVISLl71uJRnp8xCZYixSda44STpfKIxwKVbKt0ELjWkos3e7Ksh4omizBR p71MDoyAo0dSfQMWgr79mpySBIZ/q/Mber4DqvaHVfpUPRSLytvBdmxnbx++Hr8d8YEI mSQq1isYnoDapsKXvI4x25oClYfjZUZkTtQYMIVsZxu+QvFlDBqUv7vdikvCKt+Vh7lk 3TJX79oAZL8PU/g01dWnU8I0h24R6M4vHLgr3euLWjLzZ5nv/2XhygL5ALSZvu1mPHes fosqD50iQFnggljgdGZH+76f9mCxIyQouOXRpE4Y69RZ9FhauVgHjRJWy11n46GfXHm1 jGOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=EJQTjyw7C/Rn0yK9V/daxdTjipBgHq3qYkne2SKS9MA=; b=yeyDYd7q5R2wSnUEk7GxYnivUqRBr8caFGVu17lJWAmSE3ILz5paJh5BJ6c4YM3NYx St3kBu6Q/XUEtBUUHaQPrgDZcMocdpz8VqBLg9uHLNDmMvXjoG+F2yEhQ1OInBNcTkyD 1hKAlWmVobj3ea4k3X2B2pS9z3YmTKU7WI0EaKWaJBLzH76gkHvXvTDVByC5Ai96/d03 VzLe3DoXLVfCLqsr47v5c59qKAhGMTUW7lxMrnyo1YrQed/Jmk6wF3LWr+yyiRfvJN4q a+vI+uF1xetB3yW7dFuN6g90CIsCkoI3y7L5yMgbMgGIlVeeWaej/WfoNBk7FUAMHb/G yESg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S0MCAvXC; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x188-v6si13151500pfx.19.2018.08.10.22.57.23; Fri, 10 Aug 2018 22:58:13 -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=@gmail.com header.s=20161025 header.b=S0MCAvXC; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727206AbeHKI16 (ORCPT + 99 others); Sat, 11 Aug 2018 04:27:58 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:38687 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727088AbeHKI16 (ORCPT ); Sat, 11 Aug 2018 04:27:58 -0400 Received: by mail-pg1-f194.google.com with SMTP id k3-v6so5306057pgq.5 for ; Fri, 10 Aug 2018 22:54:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EJQTjyw7C/Rn0yK9V/daxdTjipBgHq3qYkne2SKS9MA=; b=S0MCAvXCxzH9PH+7lMENYxcjJ2coykviiRynbNVP1Zq7/z3eYvbFx78AN55ll+umHo 6zKjO5K/lXENZ3gqJcmEdUG+ZoU4evwgGmxJtdwQS4UpzxxW/kr2kmclY8WnctrytQEx urpv+oIyNXhRh2Ccwb74eb9eFGnTMeNx6jNDatyoTu81pCCHnAtgcMdCBU6WpYXrM3dE G+n2FaeXwjqikaKKu+ipBe1ho54GV5Io3JR1lNejbTxkFPOSiBORWC6l8ZL9tqc3ota5 6rWY5oOVMvx9f0ZFfXV3Ui9jcOCyCFM3hnmSIvka7f9LEdG5pWthZitnCDQjwWQBlLCX sgFA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=EJQTjyw7C/Rn0yK9V/daxdTjipBgHq3qYkne2SKS9MA=; b=KMCE/UqzfnZVhBvThZ1Rhqv96pl6HNMN8pPZJ/tEdCiwVPOwhsO+boZPQSG6Fey66n vdDGnyQFUBKxzQJvPxb1egh5Nz3xf15siOxLdqhxGdsjFuBaNHGqlzXxpr7ptynusZwD y1j2nr8n509egKxZvsGtjwnXscQTDeeb1p+CNbO8vjeVV/hSkUBC2taYWU2hPjpfsFnp 42P1HJyi6C2bDn+lRqJJEDBP5+2AZK2lGefgVootNonA/rSvj5TWkcv1dZeXxdv2LP6A 2ja0i+usv4FT06mTBATlwzMJVrw+ScfxEJn6L0TVJGrFWVW0Gm7nTn7ExgwhXVbfzNv5 c6/A== X-Gm-Message-State: AOUpUlGBjJHQGmTD3CJ21rXlVgv+3oGTHZhP3BEBdP+IFya7OrduwxJv AXs0RAuAwpvW7R0KKm8FpuTOmlZb X-Received: by 2002:a63:9f0a:: with SMTP id g10-v6mr9107940pge.324.1533966897224; Fri, 10 Aug 2018 22:54:57 -0700 (PDT) Received: from roar.ozlabs.ibm.com (123-243-222-142.tpgi.com.au. [123.243.222.142]) by smtp.gmail.com with ESMTPSA id d19-v6sm35834209pfe.42.2018.08.10.22.54.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Aug 2018 22:54:56 -0700 (PDT) Date: Sat, 11 Aug 2018 15:54:49 +1000 From: Nicholas Piggin To: Gautham R Shenoy Cc: Akshay Adiga , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au, benh@kernel.crashing.org, huntbag@linux.vnet.ibm.com Subject: Re: [RFC PATCH 3/3] cpuidle/powernv: Conditionally save-restore sprs using opal Message-ID: <20180811155449.020de1e8@roar.ozlabs.ibm.com> In-Reply-To: <20180808154116.GA31919@in.ibm.com> References: <20180802045132.12432-1-akshay.adiga@linux.vnet.ibm.com> <20180802045132.12432-4-akshay.adiga@linux.vnet.ibm.com> <20180803000547.08a37175@roar.ozlabs.ibm.com> <20180808154116.GA31919@in.ibm.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 8 Aug 2018 21:11:16 +0530 Gautham R Shenoy wrote: > Hello Nicholas, > > On Fri, Aug 03, 2018 at 12:05:47AM +1000, Nicholas Piggin wrote: > > On Thu, 2 Aug 2018 10:21:32 +0530 > > Akshay Adiga wrote: > > > > > From: Abhishek Goel > > > > > > If a state has "opal-supported" compat flag in device-tree, an opal call > > > needs to be made during the entry and exit of the stop state. This patch > > > passes a hint to the power9_idle_stop and power9_offline_stop. > > > > > > This patch moves the saving and restoring of sprs for P9 cpuidle > > > from kernel to opal. This patch still uses existing code to detect > > > first thread in core. > > > In an attempt to make the powernv idle code backward compatible, > > > and to some extent forward compatible, add support for pre-stop entry > > > and post-stop exit actions in OPAL. If a kernel knows about this > > > opal call, then just a firmware supporting newer hardware is required, > > > instead of waiting for kernel updates. > > > > Still think we should make these do-everything calls. Including > > executing nap/stop instructions, restoring timebase, possibly even > > saving and restoring SLB (although a return code could be used to > > tell the kernel to do that maybe if performance advantage is > enough). > > So, if we execute the stop instruction in opal, the wakeup from stop > still happens at the hypervisor 0x100. On wake up, we need to check > SRR1 to see if we have lost state, in which case, the stop exit also > needs to be handled inside opal. Yes. That's okay, SRR1 seems to be pretty well architected. > On return from this opal call, we > need to unwind the extra stack frame that would have been created when > kernel entered opal to execute the stop from which there was no > return. In the case where a lossy stop state was requested, but wakeup > happened from a lossless stop state, this adds additional overhead. True, but you're going from 1 OPAL call to 2. So you still have that overhead. Although possibly we could implement some special light weight stackless calls (I'm thinking about doing that for MCE handling too). Or you could perhaps just discard the stack without needing to unwind anything in the case of a lossless wakeup. > > Furthermore, the measurements show that the additional time taken to > perform the restore of the resources in OPAL vs doing so in Kernel on > wakeup from stop takes additional 5-10us. For the current stop states > that lose hypervisor state, since the latency is relatively high (100s > of us), this is a relatively small penalty (~1%) . Yeah OPAL is pretty heavy to enter. We can improve that a bit. But yes for P10 timeframe it may be still heavy weight. > > However, in future if we do have states that lose only a part of > hypervisor state to provide a wakeup latency in the order of few tens > of microseconds the additional latency caused by OPAL call would > become noticable, no ? I think so long as we can do shallow states in Linux it really won't be that big a deal (even if we don't do any of the above speedup tricks). I think it's really desirable to have a complete firmware implementation. Having this compromise seems like the worst of both in a way (does not allow firmware to control everything, and does not have great performance). > > > > > > I haven't had a lot of time to go through it, I'm working on moving > > ~all of idle_book3s.S to C code, I'd like to do that before this > > OPAL idle driver if possible. > > > > A minor thing I just noticed, you don't have to allocate the opal > > spr save space in Linux, just do it all in OPAL. > > The idea was to not leave any state in OPAL, as OPAL is supposed to be > state-less. However, I agree, that if OPAL is not going to interpret > the contents of the save/area, it should be harmless to move that bit > into OPAL. > > That said, if we are going to add the logic of determining the first > thread in the core waking up, etc, then we have no choice but to > maintain that state in OPAL. I don't think it's such a problem for particular very carefully defined cases like this. Thanks, Nick