From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CBADC04E53 for ; Wed, 15 May 2019 19:57:00 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6AE2D20818 for ; Wed, 15 May 2019 19:56:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=swemel.ru header.i=@swemel.ru header.b="yVTx+U6N" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6AE2D20818 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=swemel.ru Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.91) (envelope-from ) id 1hR00z-0007ee-OS; Wed, 15 May 2019 15:56:37 -0400 Received: from mail.swemel.ru ([79.135.238.163]) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1hQxX7-00061a-Cf for kernelnewbies@kernelnewbies.org; Wed, 15 May 2019 13:17:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=swemel.ru; s=17022016; h=Subject:Content-Transfer-Encoding:Content-Type:To:MIME-Version :From:Date:Message-ID; bh=oqg94qNqZXpmUOuLO0coqU+m3+uGlQ0D4LnNmpXRiqk=; b=yVT x+U6Nt/mYEacIojHzw6szoO9ny4H/LTde1Yo+mtww4SN+m8SVUqwM6yDAhu3MnJw/ptGZ517mouCX Am8YuBtaY5gImklDx3ZZaS7CwWi16CB8D3viQi/fr2vS/zo1r6rixUZoN2XmMDXoGA2cnfOjf3+xh at0a1PS5N+nznA=; Received: from [10.1.20.204] (helo=mail.swemel.grp) by mail.swemel.ru with esmtp (Exim 4.86_2) (envelope-from ) id 1hQxX1-0005pq-5s for kernelnewbies@kernelnewbies.org; Wed, 15 May 2019 20:17:33 +0300 Received: from [10.1.200.208] ([10.1.200.208]) by mail.swemel.grp with Microsoft SMTPSVC(6.0.3790.4675); Wed, 15 May 2019 20:17:31 +0300 Message-ID: <5CDC49AA.6090201@swemel.ru> Date: Wed, 15 May 2019 20:17:30 +0300 From: Konstantin Andreev Organization: Swemel JSC User-Agent: Mozilla/5.0 (X11; SunOS i86pc; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: kernelnewbies@kernelnewbies.org X-OriginalArrivalTime: 15 May 2019 17:17:31.0114 (UTC) FILETIME=[1426ECA0:01D50B42] X-SA-Exim-Connect-IP: 10.1.20.204 X-SA-Exim-Mail-From: andreev@swemel.ru Subject: How does [=rcu_dereference_protected(ptr, 1)] differ from simple [=ptr]? X-SA-Exim-Version: 4.2.1 (built Sun, 16 Aug 2015 09:47:37 +0000) X-SA-Exim-Scanned: Yes (on mail.swemel.ru) X-Mailman-Approved-At: Wed, 15 May 2019 15:56:36 -0400 X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: kernelnewbies-bounces@kernelnewbies.org Hi, according to the documentation, [rcu_dereference_protected( ptr, condition )] is the "update-side primitive" that reads the ptr, "allowing the code to verify that the required locks really are held". Given that, I expect that literal `1' as `condition' would imply just "reading the ptr". Indeed, the macro expansion of = rcu_dereference_protected( ptr, 1 ) is roughly equals to just = ({ (typeof(*ptr) *)ptr; }) i.e. simple = ptr that agrees with my expectation. So, coding [rcu_dereference_protected( ..., 1 )] looks like a waste of key presses. However, expression [rcu_dereference_protected( ..., 1 )] routinely appears in the kernel sources, many times. Why? Did I miss something? Regards, Konstantin. _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies