Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1128645pxx; Fri, 30 Oct 2020 02:50:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbhN3XVV0rk58bH9M6mb1kfBUAZDfqc1OkREjf4BoaSEb8cwHdj2zzS4Hx/XLhT+HBIfUz X-Received: by 2002:a05:6402:19ae:: with SMTP id o14mr1299474edz.67.1604051449189; Fri, 30 Oct 2020 02:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604051449; cv=none; d=google.com; s=arc-20160816; b=iCqajsnSeTepd84Xb9gslZJ8bz9+YbhtO8958TopvXnKvj4KiImwB8GthohegfskGC +w5KlNEvhiXfA642XPEDgAGqpHc1B34CUMdB80erJm6ywMVOHbn1+xidC+ume43AEJBd kHQj/OFAthiDUd1PRvf9majc7gmM6Zro3CgmJxOCErTflGuSBRg3dxpCyFY7e0XL/qXA 8ep2RKYd+d/hfpiL6/UrFDb7Ab9+5ga77ijcwLiyiNMGRWBrG2p0gUOGnsNS//EwsLYQ byUYZ38S577qsD7ZMThAD9TlWt6Gd3QIDPdGDyuICmoK/UImL8pi6mweHnr4xkMjtZ7w ynQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=+LBudHtdJLVEGjLfWv70NVtVBIwknqv23+2wyub0jE4=; b=BYedjJGsKJwYTjjyvwKomCKZwYJjsUG3INZVfgNWEX+ZWTv6vIjWzjVsqBno6pNOEN izPnA+Fg4k02JV+TjMybO2nw28t245Dp26993JiWJd3KTHPdENFjpH2OJk84oncgeUJf 0dKB6V+baSXBMCZ4h3ZfmFWRj/TmJ7I0n4lsvo86EQkDo9LquWz9v+UKc5gXIyx1reg/ m3YrIoHAUxxGWowkZpdd+sJBoP7SkQ8akwBU8Vero9gXFsI3ROMG8uy6bGFKWMXeahLT pIsK5CGiLdX8lvi9tKJGzBfFWCRcQItzo2r5M9So30iT3BZ1ocEjDCxXTXQ1VwIWIVvD 39mw== 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 r12si3661536ejx.247.2020.10.30.02.50.25; Fri, 30 Oct 2020 02:50:49 -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 S1726267AbgJ3JtB (ORCPT + 99 others); Fri, 30 Oct 2020 05:49:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:34668 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726208AbgJ3JtB (ORCPT ); Fri, 30 Oct 2020 05:49:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 51838AC77; Fri, 30 Oct 2020 09:48:59 +0000 (UTC) Date: Fri, 30 Oct 2020 10:48:58 +0100 (CET) From: Miroslav Benes To: Steven Rostedt cc: Petr Mladek , linux-kernel@vger.kernel.org, Masami Hiramatsu , Andrew Morton , Josh Poimboeuf , Jiri Kosina , Joe Lawrence , live-patching@vger.kernel.org Subject: Re: [PATCH 6/9] livepatch/ftrace: Add recursion protection to the ftrace callback In-Reply-To: <20201029142406.3c46855a@gandalf.local.home> Message-ID: References: <20201028115244.995788961@goodmis.org> <20201028115613.291169246@goodmis.org> <20201029145709.GD16774@alley> <20201029142406.3c46855a@gandalf.local.home> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > > + bit = ftrace_test_recursion_trylock(); > > > > + if (bit < 0) > > > > + return; > > > > > > This means that the original function will be called in case of recursion. > > > That's probably fair, but I'm wondering if we should at least WARN about > > > it. > > > > Yeah, the early return might break the consistency model and > > unexpected things might happen. We should be aware of it. > > Please use: > > > > if (WARN_ON_ONCE(bit < 0)) > > return; > > > > WARN_ON_ONCE() might be part of the recursion. But it should happen > > only once. IMHO, it is worth the risk. > > > > Otherwise it looks good. > > Perhaps we can add that as a separate patch, because this patch doesn't add > any real functionality change. It only moves the recursion testing from the > helper function (which ftrace wraps all callbacks that do not have the > RECURSION flags set, including this one) down to your callback. > > In keeping with one patch to do one thing principle, the added of > WARN_ON_ONCE() should be a separate patch, as that will change the > functionality. > > If that WARN_ON_ONCE() breaks things, I'd like it to be bisected to another > patch other than this one. Works for me. Miroslav