Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1969492imm; Sun, 23 Sep 2018 16:31:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV62j7qOEkZvaGekIYlWJCwSbAnDG8IKpF7zvOZ+FYgvaJmbCNTyo0eIHh4gcvfjDHAZLbFR2 X-Received: by 2002:a17:902:e85:: with SMTP id 5-v6mr7918810plx.73.1537745502147; Sun, 23 Sep 2018 16:31:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537745502; cv=none; d=google.com; s=arc-20160816; b=LZ4XO4qEIXhASWk+/GtiPuEt+1gVM0q58jLzlmxSa5paL5+roLvZRfN2G8bV17tGsY HaxOgD48raraohzMqXM948YeZAOFMA22rC1OCjeU+UW5WMNxTZKIizArHA0LSxOh4MEd HPRkXCRrshD2OiE0MdoUSkOAOLsmso7qcljItRF7HtDX1ALWgbex6bunAgELAVW0I7rM o/qbKpqCHBXSkpQgVSchjgaylsKg3NDv8J8E9AF8nvuTET8sbC/fEciZaGDhODogJJ31 yom5rDuwC71+52aZbFuuw79A2IFcWRhJrU1qpd0wPGKcP25HR2bhkLf/p3LDSXUGysfU 7ZRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :mime-version:dkim-signature; bh=5/0S7ZZuNL7DoRdL2DClTWnhoqsIKGVG4whpC4upEHA=; b=V6n6WFJ93IU/KTWuET/gZiZ6dftgZ97QVZOCQ2We5wByKrbKFTZcpAofFMth3+/g4v SVwnnl4qABWHQBLwmywjSkuWSt0+4V6RztQqJubbuHG6LGIzwooqdcvQ6fQNyENoD5h1 GZ/xwizKsFoDrFHJ1oanx8HC0X8KafzS0i5n3le3BaMumSdbxSLX7u8vtskehgNjGObJ 2MdLPFc3Lh4k2XzN6BZxpGeJk1PN/4TLPsTkgbHtXvbdMB6eJHDKQWUTkPao5pL4eFh3 aFFq98blDqZicjpG2pLiAPAiegLfAeZWJTy38Ke15Xvu7KazglKrsqAg9Tjd55ltGBCl WJYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=Nfo8qejq; 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 j6-v6si1512838pgb.62.2018.09.23.16.30.52; Sun, 23 Sep 2018 16:31:42 -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=@joelfernandes.org header.s=google header.b=Nfo8qejq; 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 S1726339AbeIXFaG (ORCPT + 99 others); Mon, 24 Sep 2018 01:30:06 -0400 Received: from mail-lf1-f41.google.com ([209.85.167.41]:40682 "EHLO mail-lf1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725902AbeIXFaG (ORCPT ); Mon, 24 Sep 2018 01:30:06 -0400 Received: by mail-lf1-f41.google.com with SMTP id t22-v6so5383161lfb.7 for ; Sun, 23 Sep 2018 16:30:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=mime-version:from:date:message-id:subject:to:cc; bh=5/0S7ZZuNL7DoRdL2DClTWnhoqsIKGVG4whpC4upEHA=; b=Nfo8qejqm+wT9diZh4z2RLa0Ign6qZV5D0tsU/rQ+K314+9hK2HI6BkzogEaSn1bKk KrUpa9RTYEfLC8SRcJZt5U9PM+q0FXLDFUrwiIq1S9GNuY7V+jGFHPsEXC7szU8gEuKa GbT8SVGcSWmUhTTIOLqtv5HQH0vdmkBUJNdVI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=5/0S7ZZuNL7DoRdL2DClTWnhoqsIKGVG4whpC4upEHA=; b=jrDnT9ab1jJQC3PrRcwoQXeiA+37sSR9aq/iIJD5ZtAZdBYMg9tvE67Yoxnz24mlcL lLZTmy+4QFGJDQGFDKKAZ6a52SdB4ftHXcDMDpyh2DFYW/gZZ89qBj5n3KUsGzYzfPev yOBThF7h5cUW6jLBZvOpnRl66dFT7+eFV6sVflzqyyAW5ebzx+CI+YFm9JFw+N0iVueS aD/fIEciEYwxfX4cm4sFgOG2nViYks/1GjbZy5/Sy5qtg/BWAqGGerKIF++YxGhUVwXp mhWv3qTmMfLo+DCd3fZydOw7UvhmKcVAmkL9fXgbbNF8n7AymP45dS+rldhbeKVAhkQ8 fXrQ== X-Gm-Message-State: APzg51Cms6a9f0/sAqV+rHK+HqTlod0QqbEDJtRQEX3jRhaKc+zeGeL8 aZEqrRsOoCrWGmGrmTThdPe0Epnjho0bVmjiTcVzFWH9GVs= X-Received: by 2002:a19:e495:: with SMTP id x21-v6mr4386876lfi.29.1537745441713; Sun, 23 Sep 2018 16:30:41 -0700 (PDT) MIME-Version: 1.0 From: Joel Fernandes Date: Sun, 23 Sep 2018 19:30:30 -0400 Message-ID: Subject: Question about ->head field of rcu_segcblist To: "Paul E. McKenney" Cc: LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, I was parsing the Data-Structures document and had a question about the following "Important note" text. Could it be clarified in the below text better why "remaining callbacks are placed back on the RCU_DONE_TAIL segment", is a reason for not depending on ->head for determining if no callbacks are associated with the rcu_segcblist? If callbacks are added back to the DONE_TAIL segment, then I would think rcu_head should be != NULL. Infact the "rsclp->head = *rsclp->tails[RCU_DONE_TAIL];" in rcu_segcblist_extract_done_cbs should set the ->head to NULL if I understand correctly. Important note: It is the ->len field that determines whether or not there are callbacks associated with this rcu_segcblist structure, not the ->head pointer. The reason for this is that all the ready-to-invoke callbacks (that is, those in the RCU_DONE_TAIL segment) are extracted all at once at callback-invocation time. If callback invocation must be postponed, for example, because a high-priority process just woke up on this CPU, then the remaining callbacks are placed back on the RCU_DONE_TAIL segment. Either way, the ->len and ->len_lazy counts are adjusted after the corresponding callbacks have been invoked, and so again it is the ->lencount that accurately reflects whether or not there are callbacks associated with this rcu_segcblist structure. Of course, off-CPU sampling of the ->len count requires the use of appropriate synchronization, for example, memory barriers. This synchronization can be a bit subtle, particularly in the case of rcu_barrier(). Thanks! - Joel