Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1229425ybh; Thu, 12 Mar 2020 20:11:38 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuDf0ejQrG6WvvqqOwpSldkNm7DGa+gM3wtDDBUNZ7s/gq702B1z80GUnzFPP1mLq+5v3FG X-Received: by 2002:a05:6830:114f:: with SMTP id x15mr9048104otq.306.1584069098222; Thu, 12 Mar 2020 20:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584069098; cv=none; d=google.com; s=arc-20160816; b=Xm8pJ04oN5+4nrWhDIaLvhmiHUd7s1v0VvhkW5R/8aXcpIfQWYtvXxJLbCZTXFbOx+ gQ3dvrBY3+ErZKP17cZBI6zSZQoFXfSw15j1WXht0l01WHYgaXsWT36+O+GyJQ8ZV2Cb PCy1Ozpo+iElwiAdEL+mL0b2sDvf4DMZNrD2Bb3a5j1AuLkmyOUzHyg7Jk76uDnzpW9i vpdsK1XVV8vhya/af5AEqY532i5m9tI00llawTptVrfCJ3D4A+/ekKe02UE82ClVO/sA 7DO6Uj3wOZIgYY/Wlg0lUOeWMOqBSUCiV6Z8x8Y2iFkpeaH4WHFyjrACtYFpFyPOF0rf MO+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=hbgniz1KICHBiyzs7HbcZAYxLQx9yaTRfc0Ur6qyrFA=; b=XYmJTtpyr/6WiDpTp3ogIAc/v7uuOR5jvXZURKKJ+5auJccf+BwcpoC1czuXFzdahJ CF3QkU5B62S/JFIvR+iYXn4KIpkT2zf4D+ph8kUcdzUnqkIdZlGSL6fajW58RxK7u6hC k/10ykays0XmxA1AseEV9D2MfQcrtspbAvYzO8txONwaTb3rc4sufrrr1FjCzeV8K6h3 Y0hZa9Vac6HSujbTU8WruKHsbMrv0fBiw7vU4QSPziiM4B4BNNqUvjB2WpZtquLkjXzX KXuEn8ueb3mO/W9Rd0mcWGQUWGVBtJ27pJN5BuJvtwpD8hnvxVxv3T1UmTjpeuiCCk6T ZY5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l6zu35EC; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t193si3982346oih.61.2020.03.12.20.11.25; Thu, 12 Mar 2020 20:11:38 -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=pass header.i=@gmail.com header.s=20161025 header.b=l6zu35EC; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726480AbgCMDKC (ORCPT + 99 others); Thu, 12 Mar 2020 23:10:02 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:38984 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726331AbgCMDKC (ORCPT ); Thu, 12 Mar 2020 23:10:02 -0400 Received: by mail-oi1-f193.google.com with SMTP id d63so7886951oig.6 for ; Thu, 12 Mar 2020 20:09:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=hbgniz1KICHBiyzs7HbcZAYxLQx9yaTRfc0Ur6qyrFA=; b=l6zu35EC5jZiSfiq/F2OiEI3o+cXYB3vRgVYlzUUW38s2rRFBgCbMoX2dURMXnz1O2 bjQYfFrwHKL+Q1YDqnLGN+q/UWu+HiNdg9rea1Ror1O2EUWpBJjyTwgEWFw/YRBVe9jz sibZCw8AfomDGgwi8Muqr2bIaUYa1R8hGck3BtsURH70MTLpHNr0VGBYyCZ3jgDH6gx/ PbYzvj7HOk8ClVcY6+nGuHswmzc6fnnl6wcKz9f149IQB9xQVe9IytyZ9VMvPGmgKjf1 KvuL0amDV7YQnFNBSB8rHDd32dLBGpDlj7pLpXoS221kPK5b96LP7vfYlaRS5UrGoD7+ VNFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=hbgniz1KICHBiyzs7HbcZAYxLQx9yaTRfc0Ur6qyrFA=; b=HRxgDDCxxFs3gw46SrC8LwaqkdNcVyEGoMTHwQ5cQnoDyHWLo4A+pa7Ne0t11w6KYN /3HqArLBVtfK7poKPuf2HuxUrJdQykRBViwZcNDlUW1qqpwd8BEOT3EqaibTtxAYpE4U 46LRykzCpApVkRu0u8JMBx6KrkSVvZNi6o7WXiSsSO/bCfuEMjX08YfEbjR7R/WJD38G 4FN5L+IgNfeXgU7ts+ATRtmyt/NMeZA93MPQ7yTw2U3VdLg+7f+8igjZE3Gv60L9kqzl h/HS34mei/9ofKGMg2s8ofqnhF0CcUETobO1ljXYK+KZFcPemkmfpXCIo/qZJ3uTHJXz 2uOA== X-Gm-Message-State: ANhLgQ218SHMjZUlFIm1hOM52qFc5whtS5e40ph6HuoJtPcRBgLHFTDq HMNnuP9jLck/PqoYqE3kwYpu0QiC X-Received: by 2002:aca:5f87:: with SMTP id t129mr5460231oib.36.1584068997580; Thu, 12 Mar 2020 20:09:57 -0700 (PDT) Received: from localhost.localdomain ([205.204.117.32]) by smtp.gmail.com with ESMTPSA id k21sm5794812otn.58.2020.03.12.20.09.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Mar 2020 20:09:57 -0700 (PDT) From: ling.ma.program@gmail.com To: linux-kernel@vger.kernel.org Cc: ling.ml@antfin.com Subject: [RFC PATCH] locks:Remove spinlock in unshare_files Date: Fri, 13 Mar 2020 11:10:17 +0800 Message-Id: <20200313031017.71090-1-ling.ma.program@gmail.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 1.8.3.1