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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 E85A7C3A5A7 for ; Wed, 4 Sep 2019 15:32:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BF678208E4 for ; Wed, 4 Sep 2019 15:32:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731279AbfIDPcv (ORCPT ); Wed, 4 Sep 2019 11:32:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36382 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729773AbfIDPcv (ORCPT ); Wed, 4 Sep 2019 11:32:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C799800DD4; Wed, 4 Sep 2019 15:32:51 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.63]) by smtp.corp.redhat.com (Postfix) with SMTP id 2883C5D9C9; Wed, 4 Sep 2019 15:32:48 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 4 Sep 2019 17:32:49 +0200 (CEST) Date: Wed, 4 Sep 2019 17:32:46 +0200 From: Oleg Nesterov To: Frederic Weisbecker Cc: "Eric W. Biederman" , Linus Torvalds , Russell King - ARM Linux admin , Peter Zijlstra , Chris Metcalf , Christoph Lameter , Kirill Tkhai , Mike Galbraith , Thomas Gleixner , Ingo Molnar , Linux List Kernel Mailing , Davidlohr Bueso Subject: Re: [PATCH 1/3] task: Add a count of task rcu users Message-ID: <20190904153245.GF24568@redhat.com> References: <20190830160957.GC2634@redhat.com> <87o906wimo.fsf@x220.int.ebiederm.org> <20190902134003.GA14770@redhat.com> <87tv9uiq9r.fsf@x220.int.ebiederm.org> <87k1aqt23r.fsf_-_@x220.int.ebiederm.org> <87ef0yt221.fsf_-_@x220.int.ebiederm.org> <20190904144415.GB20391@lenoir> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190904144415.GB20391@lenoir> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Wed, 04 Sep 2019 15:32:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/04, Frederic Weisbecker wrote: > > So what happens if, say: > > > CPU 1 CPU 2 > -------------------------------------------------------------- > rcu_read_lock() > p = rcu_dereference(rq->task) > if (refcount_inc_not_zero(p->rcu_users)) { > ..... > release_task() { > put_task_struct_rcu_user() { > call_rcu() { > queue rcu_head in this particular case call_rcu() won't be called, so > } > } > } > put_task_struct_rcu_user(); //here rcu_users has been overwritten rcu_users won't be overwritten. But nobody should try to increment ->rcu_users, rcu_read_lock(); p = rcu_dereference(rq->task); refcount_inc_not_zero(p->rcu_users); is already wrong because both release_task/last-schedule can happen in between, before refcount_inc_not_zero(). Oleg.