Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp326285imm; Wed, 17 Oct 2018 00:20:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV62iqF4iVC7FqBEZRuWY8yVgYFJbVYUilku6KPkQgJCSKbF4xwsw+/F1eCybcc4B8ueVImIS X-Received: by 2002:a17:902:24b:: with SMTP id 69-v6mr25434779plc.280.1539760835603; Wed, 17 Oct 2018 00:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539760835; cv=none; d=google.com; s=arc-20160816; b=c355ri5fEdX83NE5MxPommh9Ibii8X9IYgaz8SzGfsZLsO4JmhHtO+XJfKMShPusv5 dIhNTOnLnBSGEddqMPZDNwrHq2Rh6oWE8KgR0ZDuSeTjQUsfG2MR5H6ELn7+0IFkwVsn +Ga+JwdxlpzqKbGbKBZyqrFsZAkdw6AKHatuRJH559ia5YbcO4CsUStNMCLcwRs2SqWd EGphAKCsrKY85VnmHT6NchJJUzYgL5ktiEw3hwspejjiboKD32ye/vPNe9VxzVKE1yiM RDzkeHDyR2n2D/M5KGiSFcpu++dm+RIQNo6W7noHMwEp6fBotzz6mbpXBEZDUiV/lCOd TaeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date; bh=qvSCMfsNdrL3WZsRZxc9EXoVZydtwC91AzEYNKROoyI=; b=fkyWuEiNBBnZw7cxSIG+IVhzhxi50iEqm2rz2nkXI1y7NDfa8okfmfpK9+yZVtHeTa sepzE+csXk1RVubZ0mJDfKNVk+a5OgtX3mML2LEZunCIYrUIrACETimx46AiK2tRQZfA L7n2yRu0f7Pql0+Ju9tPOZsQvlzTObss6/QWTMf3bKgWjIr4dGZxeO++g7g2qmim+mVT QcMK4MAAdFTyX8hdoG3WZOlst0sReJpkOUbIYjX89K32EuLBUxVWrFXT+5h+w/pZxVgl CSV+65Td+y5xKgJRgIxkx8qHtrvQt3Ut0CGROhJ5j9V9XVR9sCQPD9zDB94zx+/n5HB/ /gDA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r29-v6si18804207pff.262.2018.10.17.00.20.19; Wed, 17 Oct 2018 00:20:35 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727585AbeJQPOG (ORCPT + 99 others); Wed, 17 Oct 2018 11:14:06 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37630 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727550AbeJQPOF (ORCPT ); Wed, 17 Oct 2018 11:14:05 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9H7Ipdl021996 for ; Wed, 17 Oct 2018 03:19:46 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n5x40pwat-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 17 Oct 2018 03:19:46 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 17 Oct 2018 08:19:43 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 17 Oct 2018 08:19:36 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9H7JZgD61210778 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 17 Oct 2018 07:19:35 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B86814204C; Wed, 17 Oct 2018 07:19:35 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9E1842045; Wed, 17 Oct 2018 07:19:31 +0000 (GMT) Received: from linux.vnet.ibm.com (unknown [9.126.150.29]) by d06av24.portsmouth.uk.ibm.com (Postfix) with SMTP; Wed, 17 Oct 2018 07:19:31 +0000 (GMT) Date: Wed, 17 Oct 2018 12:49:31 +0530 From: Srikar Dronamraju To: Mathieu Desnoyers Cc: Peter Zijlstra , "Paul E . McKenney" , Boqun Feng , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Thomas Gleixner , Andy Lutomirski , Dave Watson , Paul Turner , Andrew Morton , Russell King , Ingo Molnar , "H . Peter Anvin" , Andi Kleen , Chris Lameter , Ben Maurer , Steven Rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes Subject: Re: [RFC PATCH for 4.21 06/16] cpu_opv: Provide cpu_opv system call (v8) Reply-To: Srikar Dronamraju References: <20181010191936.7495-1-mathieu.desnoyers@efficios.com> <20181010191936.7495-7-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20181010191936.7495-7-mathieu.desnoyers@efficios.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-TM-AS-GCONF: 00 x-cbid: 18101707-4275-0000-0000-000002CE3988 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101707-4276-0000-0000-000037D93BB1 Message-Id: <20181017071931.GA18379@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-16_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=672 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170066 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mathieu, > +static int do_cpu_opv(struct cpu_op *cpuop, int cpuopcnt, > + struct cpu_opv_vaddr *vaddr_ptrs, int cpu) > +{ > + struct mm_struct *mm = current->mm; > + int ret; > + > +retry: > + if (cpu != raw_smp_processor_id()) { > + ret = push_task_to_cpu(current, cpu); > + if (ret) > + goto check_online; > + } > + down_read(&mm->mmap_sem); > + ret = vaddr_ptrs_check(vaddr_ptrs); > + if (ret) > + goto end; > + preempt_disable(); > + if (cpu != smp_processor_id()) { > + preempt_enable(); > + up_read(&mm->mmap_sem); > + goto retry; > + } If we have a higher priority task/s either pinned to the cpu, dont we end up in busy-looping till the task exits/sleeps? > + ret = __do_cpu_opv(cpuop, cpuopcnt); > + preempt_enable(); > +end: > + up_read(&mm->mmap_sem); > + return ret; > + > +check_online: > + /* > + * push_task_to_cpu() returns -EINVAL if the requested cpu is not part > + * of the current thread's cpus_allowed mask. > + */ > + if (ret == -EINVAL) > + return ret; > + get_online_cpus(); > + if (cpu_online(cpu)) { > + put_online_cpus(); > + goto retry; > + }