Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2618706ybh; Mon, 16 Mar 2020 06:41:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsICxxTjRs6nOoRUoka+v+U2B1Uu4nWirqQNdX1qAIaPQC9rOpAem0C+a3ib2LPA69is+KF X-Received: by 2002:aca:ad88:: with SMTP id w130mr62386oie.82.1584366068483; Mon, 16 Mar 2020 06:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584366068; cv=none; d=google.com; s=arc-20160816; b=EMnPuveE4cfurkFooZYPFYLo8uR8uMAo5guyYD51nRB6nsPIujyFZG/KsP/OZL4QCx N6oKGqImxaMBX5FpAldkiiPg+kggqD11vF+SlCygqZI2373rYlQAn09irxQQBwoXv48W umQXx23VXhaDpG0+kZoWhyiT0T3I63JMk0HAJT9UHx6fRTw6N5g/GvB7zVrjdHEwv/gn sHkH1Jx/cvXsqegYayr/yU5/UuiFde7HHBzhJpFukslAmXhieIbQ1FXFHnD3QoK+Xu/S baNFhLnD1eL63guEJ3qTt6Q58OjlLg81DW5xbAsSLzFu4FdTXY4W1iHAOZxf7SJXRYRV jbHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=BaRGNKQoR/jrhx6/KSsGNdhrEF6jcrpsPC4IKGlhMFI=; b=jaWJ5D29w9Vr21xbampcDQD5fQKpgc0ZVKUjN08pU2NuxdDvzrzp7NAT2WeZM8hEzO ACq1qxu5AWBgCFgj4kkXvHnYzaTeefVccEu5sI8Twc6V4dh95oCa0g6ruiPqTt0qALov zSBl8I6lsSzeWXZWhRvByHaJY6jRNhgScmLzyN0yV/uArKNSgwDTvIvL0EXbqZpKra26 FI+qgkTvyf5gZI+Ps1oKX5kdKcpy5Vu5Io8N1omkYFp2Ix7p7D0ZuLGx62zQIajXgkP0 b2hm8ut3r6mZuNSDuw/gQ+kbyeBy9of3mRIFCf/qXNj50QfCSFetoxtULmf1T78HPE9u jO/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=WPUvthuE; 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 p1si9853723otk.236.2020.03.16.06.40.55; Mon, 16 Mar 2020 06:41:08 -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=merlin.20170209 header.b=WPUvthuE; 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 S1731370AbgCPNjY (ORCPT + 99 others); Mon, 16 Mar 2020 09:39:24 -0400 Received: from merlin.infradead.org ([205.233.59.134]:51750 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731330AbgCPNjY (ORCPT ); Mon, 16 Mar 2020 09:39:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=BaRGNKQoR/jrhx6/KSsGNdhrEF6jcrpsPC4IKGlhMFI=; b=WPUvthuEug6gpm35QMMqVvEc1P DOFr3Fi3AI9FzBrXgn9aseRLFv1dkD8MwN4Bnruv9vw0VRZVnozJfIpCpRcJ2g4gD48zWpT4FFo+6 0/8vk36awSocJEidgtN/yxqmxOY56+3rhq4N5/+EAlA6gGtqVAFKSxqvlHPVj63cNEmw01IQ2Vmv9 wNVdyHKuXDUe0L6I5OOR0hsLqeaQB1ar9Tm34kmIOTm07SW2pySxJduV6Qyz7o7PTBdFDzDZ06/Sy 7VzsmR9kxGluYjdTaI12N7QGXIH+C3opbggU+kP0ORXWzVahSF2NOLpe8zV11iUPFvqYDXpVemHWE XlSrNZOA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDpxe-0006hA-El; Mon, 16 Mar 2020 13:39:18 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 49A8330110E; Mon, 16 Mar 2020 14:39:17 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id F2A4D20B151F2; Mon, 16 Mar 2020 14:39:16 +0100 (CET) Date: Mon, 16 Mar 2020 14:39:16 +0100 From: Peter Zijlstra To: Ling Ma Cc: linux-kernel@vger.kernel.org, Ingo Molnar , "ling.ma" , viro@zeniv.linux.org.uk Subject: Re: [RFC PATCH] locks:Remove spinlock in unshare_files Message-ID: <20200316133916.GD12561@hirez.programming.kicks-ass.net> References: <20200313031017.71090-1-ling.ma.program@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 16, 2020 at 09:25:42PM +0800, Ling Ma wrote: > Any comments ? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? Also, it probably helps to Cc the right people. > 于2020年3月13日周五 上午11:09写道: > > > > From: Ma Ling > > > > Processor support atomic operation for long/int/short/char type, > > we use the feature to avoid spinlock, which cost hundreds cycles. > > > > Appreciate your comments > > Ling > > > > Signed-off-by: Ma Ling > > --- > > kernel/fork.c | 4 +--- > > 1 file changed, 1 insertion(+), 3 deletions(-) > > > > diff --git a/kernel/fork.c b/kernel/fork.c > > index 60a1295..fe54600 100644 > > --- a/kernel/fork.c > > +++ b/kernel/fork.c > > @@ -3041,9 +3041,7 @@ int unshare_files(struct files_struct **displaced) > > return error; > > } > > *displaced = task->files; > > - task_lock(task); > > - task->files = copy; > > - task_unlock(task); > > + WRITE_ONCE(task->files, copy); > > return 0; > > } AFAICT this is completely and utterly buggered. IFF task->files was lockless, like say RCU, then you'd still need smp_store_release(). But if we look at fs/file.c then everything uses task_lock() and removing it like the above is actively broken.