Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3929129ybl; Mon, 13 Jan 2020 05:11:09 -0800 (PST) X-Google-Smtp-Source: APXvYqwcbLQFIKeba2zARO4Q4NaTTTuXOS8QAYtFWYpFXIrzHEEEgP9Zg4RMIhKjiFKNWCpof0D5 X-Received: by 2002:a9d:7e99:: with SMTP id m25mr12312369otp.212.1578921069572; Mon, 13 Jan 2020 05:11:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578921069; cv=none; d=google.com; s=arc-20160816; b=vBUZZRjByNufOXGdP6kZ/ZMktjZxICuWPWQEC8/EQHLeGZWFQ9BUhnqvLOOYMsDe6P MK6AELwPB21W5WY5TmqgODoMpfgtmOo7qxs31hg+qPHKoRc5l6jLC1zPXU879z2WvDE7 8bHf2SyBCfedYIsUz/3muJdHSBd0KyeCio6O5YwwGRHLbHECOk0KDD7TpvX4ezOygfHC VIE9N0fkaGFMKYCyr0P/n8bsl648cxQdZP7oXNjfol4aSYiu2KgiIMPT5fVBryQZ9XSQ mLWAYwhnCwR240IVESjP5RaUi8B/iUJQHr3Mq7aXkjbyYKsCxm0C/LnCu9135LmhXxqL 2Ydg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=iC47RYpYMrx/fM5rzVj7T7/k3Ao/3ucHeIWywN6kD1E=; b=zZbb2i20uIS1E4XnJziPZxyU3pDcIIXVfDlEOQjwpdG6WNwGyH7e0ibncciTjUA/2l u/YP2szw45QzDGcstA/secb8G868GQNhS/7ijfpy6kJtvPLwvAg/Hk2lZIFjLmtaoFu1 9u73SQcxLTgBjbcppk9bYJXlJiLsukiDW0dZLFesahdF1jyS5UQ7plqz27YFKPJ3O7oP 1q6Tc5/nLXCmatGEw7pnDpEQVQno98XI4u7CnKr47uZrN1VvtkqDwih6tzZKHXwrqOFo 8arhSt4rVNPPB/ab05LFltmg3yr/hGbQIJRF26HY4RulYBjLBfrVAsCISFRTCeEeYuys hizA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QxahobyL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si6711901otr.293.2020.01.13.05.10.56; Mon, 13 Jan 2020 05:11:09 -0800 (PST) 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=@kernel.org header.s=default header.b=QxahobyL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727014AbgAMNJ6 (ORCPT + 99 others); Mon, 13 Jan 2020 08:09:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:50942 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726593AbgAMNJ6 (ORCPT ); Mon, 13 Jan 2020 08:09:58 -0500 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (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 3E13D2081E; Mon, 13 Jan 2020 13:09:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578920997; bh=gyDnNoKTZ22DZEKM3QxIzE68ZWjkRDMYhM7ep5kP+vY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QxahobyLvunSkXeHTuFOBUvUoh6nvqy37qLTmDjYC57O8ERCuJYtmkCunKXQ7Dg/r +SWipHnGylfCg4ughxj3i++/eQMiH2JGQ9FSxN/7zq1QMEVVOeVoYh4AB/Pv8DDMVD I+6BKtXViF8PCn+nhNa1aApR7pS6mcgh95T01PmQ= Date: Mon, 13 Jan 2020 22:09:53 +0900 From: Masami Hiramatsu To: Masami Hiramatsu Cc: Joel Fernandes , Ingo Molnar , Anders Roxell , paulmck@kernel.org, "Naveen N . Rao" , Anil S Keshavamurthy , David Miller , Linux Kernel Mailing List Subject: Re: [PATCH -tip V2 0/2] kprobes: Fix RCU warning and cleanup Message-Id: <20200113220953.dccefd4846d004ee5a5b3295@kernel.org> In-Reply-To: <20200113121640.bfab48c105dae9b1918c2d82@kernel.org> References: <157535316659.16485.11817291759382261088.stgit@devnote2> <20191221035541.69fc05613351b8dabd6e1a44@kernel.org> <20200107211535.233e7ff396f867ee1348178b@kernel.org> <20200110211438.GE128013@google.com> <20200111083507.c32b85b1d47aa69928de530b@kernel.org> <20200112020537.GJ128013@google.com> <20200113121640.bfab48c105dae9b1918c2d82@kernel.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joel, On Mon, 13 Jan 2020 12:16:40 +0900 Masami Hiramatsu wrote: > > > > > > > > Hi Masami, > > > > > > > > I believe I had commented before that I don't agree with this patch: > > > > https://lore.kernel.org/lkml/157535318870.16485.6366477974356032624.stgit@devnote2/ > > > > > > > > The rationale you used is to replace RCU-api with non-RCU api just to avoid > > > > warnings. I think a better approach is to use RCU api and pass the optional > > > > expression to silence the false-positive warnings by informing the RCU API > > > > about the fact that locks are held (similar to what we do for > > > > rcu_dereference_protected()). The RCU API will do additional checking > > > > (such as making sure preemption is disabled for safe RCU usage etc) as well. > > > > > > Yes, that is what I did in [1/2] for get_kprobe(). > > > Let me clarify the RCU list usage in [2/2]. > > > > > > With the careful check, other list traversals never be done in non-sleepable > > > context, those are always runs with kprobe_mutex held. > > > If I correctly understand the Documentation/RCU/listRCU.rst, we should/can use > > > non-RCU api for those cases, or do I miss something? > > > > Yes, that is fine. However personally I prefer not to mix usage of > > list_for_each_entry_rcu() and list_for_each_entry() on the same pointer > > (kprobe_table). I think it is more confusing and error prone. Just use > > list_for_each_entry_rcu() everywhere and pass the appropriate lockdep > > expression, instead of calling lockdep_assert_held() independently. Is this > > not doable? > > Hmm, but isn't it more confusing that user just take a mutex but > no rcu_read_lock() with list_for_each_entry_rcu()? In that case, > sometimes it might sleep inside list_for_each_entry_rcu(), I thought > that might be more confusing mind model for users... I meant, do we always need to do something like below? { mutex_lock(&lock); list_for_each_entry_rcu(list, ..., lockdep_is_held(&lock)) { ... } mutex_unlock(&lock); } BTW, I found another problem on this policy, since we don't have list_for_each_*_safe() equivalents for RCU, we can not do a safe loop on it. Should we call a find function for each time? Thank you, -- Masami Hiramatsu