Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4206487ybi; Tue, 11 Jun 2019 02:47:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6Jj08oz2YmUefD8VBABgzSMdNPrSjQFaHsrD5JXX4IuFyYM2n+MqPfpjIPa4JKmcMrVrs X-Received: by 2002:a17:902:b944:: with SMTP id h4mr72673988pls.179.1560246434162; Tue, 11 Jun 2019 02:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560246434; cv=none; d=google.com; s=arc-20160816; b=xs0aJ+Hb3d4/aq4cCM6Sr/cN1XeKAABJOzxceU3tgyBD0NZkP+x/pWOYkxhC98yKgZ 6vHBNo5r5bPCYD/ylz9xhEh5kw+orhN2L9c+8DzGCyGAgGrjJJ+7KehSCO9YmdR2JRzT 4O9gOpnKOPpbYRjo3D+wZQ4lfvNqQuIz1HNU/zpfTyNCWgExLD5mnFoTmMadEmhvPyyK BLkvo4iz/x0cOZPUqLCtA/dgFjvg/60S8t0yF9hcl+vR7yG/i5fBODtN5XgUtETBHBH6 BxQxz6QvhPIJ3IL8wvMUdRGNbQJDYfdYrILFaVjhoUWl1u4Tnwf7Rp8mmOEtcaDDCIY+ 597A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=VEECxa63lSDae44YYA0SmkX/nnYgGF1NhyGuBAx1jCI=; b=ZQrYZuVemNiqB+YYjhltORdtxTuznVZ6IpdsGQ55Eeb6ob/iPvJjJbamL3UtmNkMQ6 JInZ2/bbFWJMWeugeWFrJNg1bicAqyHTV/RGWPsmIHew9GIZ3P3wOXqoUkyebb9C17Es z+EaSDN8Pn27w+rmfoiExyC4+wTEkgXWAGJYBalC508imnuh3ph4HeFFNSu2wZlsrXx0 7sZC/tzyfY6i8Bmp6fb6dGwTXiNKDRz6whn36r4AewYuz5CDMctvaLkavpFPhKPxLo6o AyKzRVGXC0n8JOErMRj4oh6EXYOzGBglirclCtkRGQEmBtlQWco0JyyYne/4EP5K2y4z uD3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XCNS03ho; 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 b23si11564905pls.291.2019.06.11.02.46.33; Tue, 11 Jun 2019 02:47:14 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XCNS03ho; 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 S2404258AbfFKJP4 (ORCPT + 99 others); Tue, 11 Jun 2019 05:15:56 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:33672 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727642AbfFKJP4 (ORCPT ); Tue, 11 Jun 2019 05:15:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=VEECxa63lSDae44YYA0SmkX/nnYgGF1NhyGuBAx1jCI=; b=XCNS03hoWW8vU0KkhyVxGPJ6f n+Nq9eTPb2heNUo12nB3A4BhWw98SyHCSRjyFfNtBC00CtsfVPJFVhxv0Ke/4QOAxZXg81dp9TF6N BkZptKuD3RWSih9ooyCN5h506xvu0nilbBx8XTBlPHo6dvOyvVHaMrXTqonIGn7myRieJUvIHahRD G4ZqdLy5csut//3VWHVkbk0AEOIR9KxWxiiLJkvRPlClaIaI6BqoFxT+9ZSx7JK3q/RiMCIGzG8II etomQjJ1NReKz5VoBcGkXNg3dAmPeQDECmWb+cbOLova0UTApObf4FpXfkyB1hQZnYJzVZhy/6QkP y+dpLbAdg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hacse-00069J-8B; Tue, 11 Jun 2019 09:15:48 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 54CF8202173E3; Tue, 11 Jun 2019 11:15:46 +0200 (CEST) Date: Tue, 11 Jun 2019 11:15:46 +0200 From: Peter Zijlstra To: Heiko Carstens Cc: Thomas Gleixner , Christian Borntraeger , Michael Ellerman , Paul Mackerras , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: Re: [PATCH/RFC 2/3] s390: improve wait logic of stop_machine Message-ID: <20190611091546.GV3436@hirez.programming.kicks-ass.net> References: <20190608110853.35961-1-heiko.carstens@de.ibm.com> <20190608110853.35961-3-heiko.carstens@de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190608110853.35961-3-heiko.carstens@de.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 08, 2019 at 01:08:52PM +0200, Heiko Carstens wrote: > --- a/arch/s390/kernel/processor.c > +++ b/arch/s390/kernel/processor.c > @@ -31,6 +31,7 @@ struct cpu_info { > }; > > static DEFINE_PER_CPU(struct cpu_info, cpu_info); > +static DEFINE_PER_CPU(int, cpu_relax_retry); > > static bool machine_has_cpu_mhz; > > @@ -58,13 +59,21 @@ void s390_update_cpu_mhz(void) > on_each_cpu(update_cpu_mhz, NULL, 0); > } > > +void notrace cpu_relax_yield(const struct cpumask *cpumask) > { > + int cpu; > + > + if (__this_cpu_inc_return(cpu_relax_retry) >= spin_retry) { > + __this_cpu_write(cpu_relax_retry, 0); I don't mind, but do we really need a per-cpu variable for this? Does it really matter if you spin on a stack variable and occasionally spin a bit longer due to the missed tail of the previous spin? > + cpu = cpumask_next(smp_processor_id(), cpumask); > + if (cpu >= nr_cpu_ids) { > + cpu = cpumask_first(cpumask); > + if (cpu == smp_processor_id()) > + return; If this function is passed an empty cpumask, the above will result in 'cpu == nr_cpu_ids' and the below might be unhappy with that. (FWIW we do have cpumask_next_wrap(), but I admit it is somewhat awkward to use) > + } > + if (arch_vcpu_is_preempted(cpu)) > + smp_yield_cpu(cpu); > } > } > EXPORT_SYMBOL(cpu_relax_yield);