Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1930434pxk; Sat, 19 Sep 2020 06:57:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPnUedtWx5U4VgWFc1S+aJikxBPPGX/LvaiIzMQhKGczVLep6fQQ/6A4DwJJ+b9Q9gJ9hf X-Received: by 2002:a50:f1cf:: with SMTP id y15mr44599522edl.204.1600523867505; Sat, 19 Sep 2020 06:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600523867; cv=none; d=google.com; s=arc-20160816; b=EPW+XPl5mwp0EEAp/BQ5EhuYh6/9KBOnuSSFyyrJqLc/cA574jvCYD1/RuPZ/AU+t1 16cQVUTJCaELE4fUGgxeE8rUwWgjpOZMdCIwnyF39u80KOS0VQT3EI7JdBQz7oRPnLSS x7yWW/oNp8kt5hmjqtKHfeWNOuu97c6ypNpqcmzX1QiQE/THa4wp+mumtQE5/Tz5FB0a ZfSXog+GH7ZBvnhkGAEtDeCGzP05Bn6fJNTwvykI/uCDYc6QHmVgqGzlQfAbRFlIqDYR VTKGfHBM4lU06iGsynhkdFVgtKFfwMjcs6feeblVUXgC6dYWeQJ7yzIRhGFHKwqwHP+V ApNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=MCl/DSyd/nFRsnz1qAff8tmIHz+YiMl+AaxXhGGGT3M=; b=efNcSME0BhlRCp3OIFxo/Q0UJk4nH/bh2lWD+/af1zkQBgwKoL7ud8gu5yZjHUuTCE VtxTRgO+1GH62UidGeTCM9mbBVJ7TibGOvw2PsqWYDDcOpoU9JmTD9l736XWqwwcHl4/ VXXK7Ny2X432+4Pd8pKDWu3GhjTfdql577ZbKzOT0PSGPQsRyk50KQL8rVQ+USEKlrDr muRFEDmBUlgcDnIpNmLFlbwwaMV9ywg/Aahl/9EE15J4MGmBJuDsJGNl/LxeS1aUnOTY ZA7WXAreb60+6+lg9+GH79bAbGBCdhamD4rzQQpag/JxLqv7MBQxkUaBK+YhZ71+6CHt 5F7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x15si4312684ejs.713.2020.09.19.06.57.23; Sat, 19 Sep 2020 06:57:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726481AbgISN4U (ORCPT + 99 others); Sat, 19 Sep 2020 09:56:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:59612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726159AbgISN4U (ORCPT ); Sat, 19 Sep 2020 09:56:20 -0400 Received: from rorschach.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9C1C207BB; Sat, 19 Sep 2020 13:56:19 +0000 (UTC) Date: Sat, 19 Sep 2020 09:56:18 -0400 From: Steven Rostedt To: Oleg Nesterov Cc: Davidlohr Bueso , mingo@kernel.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH] fgraph: Convert ret_stack tasklist scanning to rcu Message-ID: <20200919095618.62d57b71@rorschach.local.home> In-Reply-To: <20200919112438.GA4430@redhat.com> References: <20200907013326.9870-1-dave@stgolabs.net> <20200907114301.GA31050@redhat.com> <20200918131201.53b894b4@gandalf.local.home> <20200919112438.GA4430@redhat.com> X-Mailer: Claws Mail 3.17.4git76 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 19 Sep 2020 13:24:39 +0200 Oleg Nesterov wrote: > On 09/18, Steven Rostedt wrote: > > > > On Mon, 7 Sep 2020 13:43:02 +0200 > > Oleg Nesterov wrote: > > > > > Afaics, with or without this change alloc_retstack_tasklist() can race > > > with copy_process() and miss the new child; ftrace_graph_init_task() > > > can't help, ftrace_graph_active can be set right after the check and > > > for_each_process_thread() can't see the new process yet. > > > > There's a call in copy_process(): ftrace_graph_init_task() that initializes > > a new tasks ret_stack, > > Only if ftrace_graph_active != 0. > > register_ftrace_graph() can increment ftrace_graph_active and call > alloc_retstack_tasklist() right after ftrace_graph_init_task() checks > ftrace_graph_active. > > > and this loop will ignore it > > and this loop won't see it unless the forking process finishes copy_process() > and does list_add_tail_rcu(&p->tasks, &init_task.tasks) which makes it > visible to for_each_process(). Yes, this is very unlikely. Ah, I see what you mean. Hmm, not sure the best way to fix this. It would be very rare to trigger and the only thing that it would do is not to trace the new task. But that could be frustrating if that happens. I guess we could put the hook after it gets added to the list, and use a cmpxchg to update the ret_stack, to make sure we don't race on initialization and copy_process. -- Steve