From patchwork Sat Apr 30 20:09:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Falak R Wani X-Patchwork-Id: 8987241 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 827B89F46D for ; Sat, 30 Apr 2016 20:09:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A500020173 for ; Sat, 30 Apr 2016 20:09:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF90320166 for ; Sat, 30 Apr 2016 20:09:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752455AbcD3UJa (ORCPT ); Sat, 30 Apr 2016 16:09:30 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:33680 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750759AbcD3UJ3 (ORCPT ); Sat, 30 Apr 2016 16:09:29 -0400 Received: by mail-pa0-f67.google.com with SMTP id vv3so17848684pab.0; Sat, 30 Apr 2016 13:09:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=KGsfA4IyR2fUqi/Uf6FQabn6LBVEX0g9H94AMQ0wbsU=; b=MIFgwaRd1LM3yxUhmTT0v36HkvB9vJSVaReZqkjHMOTi6pMyWFuwWzFOCMKjcX+uTP hWzRjSJwtYML3Fl5QfKsMOtdnbtr1HEaU/W5hQHaJiOBo0PyWW2okIH5SQHgsGDytfQP izBUvTXVzdiPt4SzR88e1rgvK58bmIlTdt9GX3NHsGEFpjMniJXiur855K5BbLOTkg/X 0C+K8kueCk7LnYkMXpEyJH7QFXp7Z2B/vasiOJ+wR6wfiz7UysyNwNdLTtMABcaOhjWI CK1XjOFk6wkB8hfDtCzIOnp5Lk5Ls4Buc/7UVfyH8m5TK9uZGfs0kssu+INDNGsCiNRb +cSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KGsfA4IyR2fUqi/Uf6FQabn6LBVEX0g9H94AMQ0wbsU=; b=AHJALVTwDsBIyK+HIMfj+ssqA5MUBkfRCYASD0I3xd4H3TzJ5oov5tMf4WwqlCbqv8 zirVf934FmWaG0L4BSzSfJBEhdmkEVqN7Hff5ES7Ne+pLLar0juJqI7oBGXi85z+Fqi1 pBoQIjCdljTECfes0SyKf5Y/JzQ5Hcg8RRYVUi1XeHv/+p2HXXLT8g8O2bG6FWhT4Wyi yRAyJM5BllL5hr9Pc8LJKfhTDQSOlHTbDmyh+rhBrf9eDvDuEkwckZCmhcljzXQ44WZx bgY29sRcc+rPkRAW5zBNifYTgPSzgCQi/quw8E9FRoDfuIaMnoSoX8YgZXNgrneoFD0B i5vg== X-Gm-Message-State: AOPr4FWIlbxiKlXDRrWLvOmfHlAiIyW+xah3o/2GZih3CA49LfFXuJ4RLjVOwKBx1KEmyw== X-Received: by 10.66.141.171 with SMTP id rp11mr37306149pab.92.1462046968325; Sat, 30 Apr 2016 13:09:28 -0700 (PDT) Received: from kp.domain.name ([110.235.28.83]) by smtp.gmail.com with ESMTPSA id i6sm32754550pfc.65.2016.04.30.13.09.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Apr 2016 13:09:27 -0700 (PDT) From: Muhammad Falak R Wani To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] vfs: use RCU_INIT_POINTER when NULLing Date: Sun, 1 May 2016 01:39:12 +0530 Message-Id: <1462046952-30147-1-git-send-email-falakreyaz@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is always safe to use RCU_INIT_POINTER to NULL a pointer. This results in slightly smaller/faster code. The following semantic patch used: @@ @@ - rcu_assign_pointer + RCU_INIT_POINTER (..., NULL) Signed-off-by: Muhammad Falak R Wani --- fs/file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/file.c b/fs/file.c index 1fbc5c0..e027b33 100644 --- a/fs/file.c +++ b/fs/file.c @@ -543,7 +543,7 @@ repeat: /* Sanity check */ if (rcu_access_pointer(fdt->fd[fd]) != NULL) { printk(KERN_WARNING "alloc_fd: slot %d not NULL!\n", fd); - rcu_assign_pointer(fdt->fd[fd], NULL); + RCU_INIT_POINTER(fdt->fd[fd], NULL); } #endif @@ -644,7 +644,7 @@ int __close_fd(struct files_struct *files, unsigned fd) file = fdt->fd[fd]; if (!file) goto out_unlock; - rcu_assign_pointer(fdt->fd[fd], NULL); + RCU_INIT_POINTER(fdt->fd[fd], NULL); __clear_close_on_exec(fd, fdt); __put_unused_fd(files, fd); spin_unlock(&files->file_lock); @@ -679,7 +679,7 @@ void do_close_on_exec(struct files_struct *files) file = fdt->fd[fd]; if (!file) continue; - rcu_assign_pointer(fdt->fd[fd], NULL); + RCU_INIT_POINTER(fdt->fd[fd], NULL); __put_unused_fd(files, fd); spin_unlock(&files->file_lock); filp_close(file, files);