Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp334577ybj; Thu, 19 Sep 2019 15:15:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqytJ9ZMjXKCAv37i6+X2pxi8iBZq9VH9y4VcxIhWFz1y3NQTrYykoJqNGc+LeYATb7W+Rrq X-Received: by 2002:a17:906:129b:: with SMTP id k27mr16048660ejb.42.1568931359139; Thu, 19 Sep 2019 15:15:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568931359; cv=none; d=google.com; s=arc-20160816; b=AYQw+FjQi/1kBAtE3SEuOdiOKBiDi1y8dPrN9F3fnSn4yQhtBOvciQhorbuYIaz+a9 3B2SS+6vOnJiYcfRcPcMRGwqZltszlUtB6DKRvUOgsOksG/Hlpc2U439JHyzpz7p92El MKTFCV9TCHxhUWsI35qtaLKtCGde3KBoguSZt5AQYhAGoFa+W2m8cRdg/3Xy9f8MHwv/ /QPfrl3rh4xqK2rzov3JW7ZMB3JrBP8w6FyXVBbJsv5ftF22IHj8xahWoNH7N9wMPsIn Dn82snBIRCvqnf7cpm1O3oI3swsYFZv7J0Q6fUC5kx85BfXUxUMwX7B6L3+35KY6THo4 ZNIw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=mjPaFOhLhnzC4mnvRHhzOYWMd4JMzYvqU4biZhVnBdI=; b=zqL8NXwjEjg1kAs4VYG67FffLEoBMEM+XXFWwTMevOh+1dfRKxsyYvsyY/bXJS6x/x SqAjr/NmHocV8pbnI868jA8WsyCBYbKdttKw4zNDNiDccvS8xoQra2kbP6AdnaGb21Fm K+PzkwNC0bTSC2tVMHYahpn/s8XlIrRkldkCkisAFlxqK7k96h5ClS4gewLlmZ4vOCOw DVKOgQrewA31WucNwx1sJ+iS6zwW5p/Hp/bzdUaassVM+kKfISfrK9B/8HyA5Ss7fUG2 li2FGzRtinhJz9fppjiTj5HaNcbRIvsNqU6xfuJY5adrnuIe8hrBYkeQ9J9CtTv4ZXzl Lpww== 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 f45si74353edb.166.2019.09.19.15.15.35; Thu, 19 Sep 2019 15:15:59 -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 S2392217AbfISTF4 (ORCPT + 99 others); Thu, 19 Sep 2019 15:05:56 -0400 Received: from gate.crashing.org ([63.228.1.57]:55358 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392208AbfISTFz (ORCPT ); Thu, 19 Sep 2019 15:05:55 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x8JJ5Qie013352; Thu, 19 Sep 2019 14:05:26 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x8JJ5OTA013351; Thu, 19 Sep 2019 14:05:24 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 19 Sep 2019 14:05:24 -0500 From: Segher Boessenkool To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , npiggin@gmail.com, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v3 2/2] powerpc/irq: inline call_do_irq() and call_do_softirq() Message-ID: <20190919190524.GK9749@gate.crashing.org> References: <5fb4aedadbd28b9849cf2fabe13392fb3b5cd3ed.1568821668.git.christophe.leroy@c-s.fr> <20190918163919.GH9749@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 19, 2019 at 07:23:18AM +0200, Christophe Leroy wrote: > Le 18/09/2019 ? 18:39, Segher Boessenkool a ?crit?: > >I realise the original code had this... Loading the old stack pointer > >value back from the stack creates a bottleneck (via the store->load > >forwarding it requires). It could just use > > addi 1,1,-(%2) > >here, which can also be written as > > addi 1,1,%n2 > >(that is portable to all architectures btw). > > No, we switched stack before the bl call, we replaced r1 by r3 after > saving r1 into r3 stack. Now we have to restore the original r1. Yeah wow, I missed that once again. Whoops. Add a comment for this? Just before the asm maybe, "we temporarily switch r1 to a different stack" or something. > >What about r2? Various ABIs handle that differently. This might make > >it impossible to share implementation between 32-bit and 64-bit for this. > >But we could add it to the clobber list worst case, that will always work. > > Isn't r2 non-volatile on all ABIs ? It is not. On ELFv2 it is (or will be) optionally volatile, but like on ELFv1 it already has special rules as well: the linker is responsible for restoring it if it is non-volatile, and for that there needs to be a nop after the bl, etc. But the existing code was in a similar situation and we survived that, I think we should be fine this way too. And it won't be too hard to change again if needed. > >So anyway, it looks to me like it will work. Nice cleanup. Would be > >better if you could do the call to __do_irq from C code, but maybe we > >cannot have everything ;-) > > sparc do it the following way, is there no risk that GCC adds unwanted > code inbetween that is not aware there the stack pointer has changed ? > > void do_softirq_own_stack(void) > { > void *orig_sp, *sp = softirq_stack[smp_processor_id()]; > > sp += THREAD_SIZE - 192 - STACK_BIAS; > > __asm__ __volatile__("mov %%sp, %0\n\t" > "mov %1, %%sp" > : "=&r" (orig_sp) > : "r" (sp)); > __do_softirq(); > __asm__ __volatile__("mov %0, %%sp" > : : "r" (orig_sp)); > } > > If the above is no risk, then can we do the same on powerpc ? No, that is a quite bad idea: it depends on the stack pointer not being used in any way between the two asms. Which this code does not guarantee (what if it is inlined, for example). Doing the stack juggling and the actual call in a single asm is much more safe and correct. It's just that you then need asm for the actual call that works for all ABIs you support, etc. :-) Segher