Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752227AbdHNT1d (ORCPT ); Mon, 14 Aug 2017 15:27:33 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43230 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752120AbdHNT1b (ORCPT ); Mon, 14 Aug 2017 15:27:31 -0400 Date: Mon, 14 Aug 2017 12:27:15 -0700 From: Sukadev Bhattiprolu To: Benjamin Herrenschmidt Cc: Michael Neuling , Michael Ellerman , stewart@linux.vnet.ibm.com, linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org, apopple@au1.ibm.com, oohall@gmail.com Subject: Re: [PATCH v6 14/17] powerpc: Add support for setting SPRN_TIDR References: <1502233622-9330-1-git-send-email-sukadev@linux.vnet.ibm.com> <1502233622-9330-15-git-send-email-sukadev@linux.vnet.ibm.com> <1502694131.9844.7.camel@neuling.org> <1502717435.4493.29.camel@au1.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1502717435.4493.29.camel@au1.ibm.com> X-Operating-System: Linux 2.0.32 on an i486 User-Agent: Mutt/1.7.1 (2016-10-04) X-TM-AS-GCONF: 00 x-cbid: 17081419-0024-0000-0000-000002BF828B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007544; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000220; SDB=6.00902313; UDB=6.00451907; IPR=6.00682528; BA=6.00005531; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016692; XFM=3.00000015; UTC=2017-08-14 19:27:28 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17081419-0025-0000-0000-000045186296 Message-Id: <20170814192715.GC24096@us.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-14_17:,, 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-1708140318 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1519 Lines: 45 Benjamin Herrenschmidt [benh@au1.ibm.com] wrote: > On Mon, 2017-08-14 at 17:02 +1000, Michael Neuling wrote: > > > +/* > > > + * We need to assign an unique thread id to each thread in a process. This > > > + * thread id is intended to be used with the Fast Thread-wakeup (aka Core- > > > + * to-core wakeup) mechanism being implemented on top of Virtual Accelerator > > > + * Switchboard (VAS). > > > + * > > > + * To get a unique thread-id per process we could simply use task_pid_nr() > > > + * but the problem is that task_pid_nr() is not yet available for the thread > > > + * when copy_thread() is called. Fixing that would require changing more > > > + * intrusive arch-neutral code in code path in copy_process()?. > > > + * > > > + * Further, to assign unique thread ids within each process, we need an > > > + * atomic field (or an IDR) in task_struct, which again intrudes into the > > > + * arch-neutral code. > > > > Really? > > > > > + * So try to assign globally unique thraed ids for now. > > > > Yuck! I know :-) copy_process() has: retval = copy_thread_tls(clone_flags, stack_start, stack_size, p, tls); if (retval) goto bad_fork_cleanup_io; if (pid != &init_struct_pid) { pid = alloc_pid(p->nsproxy->pid_ns_for_children); if (IS_ERR(pid)) { so copy_thread() is called before a pid_nr is assigned to the task. But see also response to Michael Ellerman. > > Also CAPI has size limits for the TIDR afaik Ok. > > Ben.