Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751960AbdHAM1F (ORCPT ); Tue, 1 Aug 2017 08:27:05 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58092 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751648AbdHAM1D (ORCPT ); Tue, 1 Aug 2017 08:27:03 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 01 Aug 2017 09:28:29 -0300 From: Victor Aoqui To: Benjamin Herrenschmidt Cc: rjw@rjwysocki.net, daniel.lezcano@linaro.org, paulus@samba.org, mpe@ellerman.id.au, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, ltc-interlock@lists.linux.ibm.com, victora@br.ibm.com, mauricfo@linux.vnet.ibm.com Subject: Re: [PATCH] drivers: cpuidle: Disable preemption before get_lppaca function call in pseries_idle_probe function In-Reply-To: <1500585713.10674.10.camel@kernel.crashing.org> References: <20170720175735.3957-1-victora@linux.vnet.ibm.com> <1500585713.10674.10.camel@kernel.crashing.org> User-Agent: Roundcube Webmail/1.0.1 X-TM-AS-GCONF: 00 x-cbid: 17080112-0044-0000-0000-0000037664CB X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007464; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000215; SDB=6.00895992; UDB=6.00448179; IPR=6.00676179; BA=6.00005506; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016481; XFM=3.00000015; UTC=2017-08-01 12:26:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17080112-0045-0000-0000-000007A475EA Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-01_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1708010206 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1630 Lines: 46 Em 2017-07-20 18:21, Benjamin Herrenschmidt escreveu: > On Thu, 2017-07-20 at 14:57 -0300, Victor Aoqui wrote: >> When CONFIG_PREEMPT=y, the following warning shows up: >> >> BUG: using smp_processor_id() in preemptible [00000000] code: >> swapper/0/1 >> caller is pseries_processor_idle_init+0x58/0x21c >> >> This warning shows up because preemption cannot occur when using >> get_paca(), otherwise the paca_struct it points to may be the wrong >> one >> just after. >> >> For this reason, preemption needs to be disabled before >> lppaca_shared_proc(get_lppaca()). > > Also chekc the generated assembly. We had all sort of interesting > issues where gcc would copy the paca pointer or the lppaca pointer > to a GPR *outside* of the preempt disabled section... > > In that specific case it's not a big deal but overall, I am not > comfortable with PREEMPT on powerpc until we do something a bit > more drastic... > > I would like to remove all such direct accesses to paca, instead have a > "new" get_paca() written in asm that does the preempt disable then > returns the PACA in a GPR (not directly use r13, hide that from gcc), > and which is paired with a put_paca(). > > The few places where we want to directly access r13 should be hand > written in asm too to hide r13 from gcc, for accessing the irq_happened > in the fast path of local_irq_enable/disable/... we should do the same > with lock tokens. > > Ben. Hi Benjamin, Sorry for the delay. I was a little bit busy last days. I took note of your comments and I will work on those changes. I will let you know soon when it's done. Thanks -- Victor Aoqui