Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp727977ybg; Mon, 1 Jun 2020 12:49:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTYqlz9+qO+HkBML4keUaJ9RIui90Bb4/awIvOxJKYzEphibgH01IyZXxYzNp1Qrvwf4ae X-Received: by 2002:a50:aacc:: with SMTP id r12mr3353345edc.219.1591040966930; Mon, 01 Jun 2020 12:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591040966; cv=none; d=google.com; s=arc-20160816; b=FRldartNvgv+6Syc/eNIuWn+tXRhtCCsrMWivlsSBanD0doQCcxgwyqPMZylabEc12 YWuV6jTm1pb2XS33Aksaq6YSqwDc60siOvBqEXrki+P3XZuRNX01KsZsOKOsq2Iy2p6L tvxQ7M+6lX8gKw7lKnMnyeCdUHfhKMXnwbvNaY1tWW4fC4ORHE+uq364QgqnMe9xWYrr 2H+dN1CqemQm7c8Gii6nH/hqstxKUMHpW5xaqsx6YsYXNsHHQH0r1i5Pb3EvUB3i9+Sb AZcWlsWRnRt26DAI3P3xTHJHiGTkv+HYOXE6ZUEZKbgcg0dcTF7KTVxmjn1wGglI/yP/ MVUQ== 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; bh=OYXk2+QWqytEXwThcsurygNZcg0eQCxASGiQzO6QUjs=; b=Cd13IyknnTdTO+R1o1imqBFZusGEVHWU1a8ctSCgalRmLcyS6VrNr2UVZVe7C75+Ae RjTnKYyXT3VMOSo56/1S0QtpaKvU4z1/OyLrSRjUewib39cmXsj2UbzizxZt/iF7B1b7 gJB+tcJvSCDUnxcXKvKkAyxqzBE0BTGkVT0+GYCi3SD9ZO7P+38Df4HZPcvM9R/ED4UQ UlBt8m4nvCS7tYR218A96sx41SdT0sLfmyY9onFw7ODejvnDC4dAZzFjhIICtVauGrVP PolQw4ytYwtwkV4Kd+C135rtKwLc4zwzV4Scc8xfNEjHpNBjzHChptYHaXUMk9qhZSzl P2Zg== 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 h14si196951edq.256.2020.06.01.12.49.03; Mon, 01 Jun 2020 12:49:26 -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 S1728216AbgFATqu (ORCPT + 99 others); Mon, 1 Jun 2020 15:46:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:37772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728118AbgFATqu (ORCPT ); Mon, 1 Jun 2020 15:46:50 -0400 Received: from oasis.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 CA00C206E2; Mon, 1 Jun 2020 19:46:48 +0000 (UTC) Date: Mon, 1 Jun 2020 15:46:47 -0400 From: Steven Rostedt To: Jules Irenge Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, paulmck@kernel.org, mingo@redhat.com, boqun.feng@gmail.com, Borislav Petkov , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "H. Peter Anvin" Subject: Re: [PATCH 4/5] x86/ftrace: Add annotations for ftrace_arch_code_modify_prepare() and ftrace_arch_code_modify_post_process() Message-ID: <20200601154647.581fa345@oasis.local.home> In-Reply-To: <20200601184552.23128-5-jbi.octave@gmail.com> References: <20200601184552.23128-1-jbi.octave@gmail.com> <20200601184552.23128-5-jbi.octave@gmail.com> X-Mailer: Claws Mail 3.17.3 (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 On Mon, 1 Jun 2020 19:45:51 +0100 Jules Irenge wrote: > Sparse reports warnings > > warning: context imbalance in ftrace_arch_code_modify_prepare() > - wrong count at exit > warning: context imbalance in ftrace_arch_code_modify_post_process() > - wrong count at exit > > The root cause is that even if > the annotations on the function are correct, > mutex do not support annotation > This makes Sparse to complain. > To fix this, > __acquire(&text_mutex) and > __release(&text_mutex) annotations are added > inside ftrace_arch_code_modify_prepare() > and ftrace_arch_code_modify_post_process() > respectively. Wait what? This looks like either a bug in sparse, or we just remove the annotations. This just makes the code ugly, and looks silly. Nack! -- Steve > > Signed-off-by: Jules Irenge > --- > arch/x86/kernel/ftrace.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c > index 37a0aeaf89e7..737c07ab2e07 100644 > --- a/arch/x86/kernel/ftrace.c > +++ b/arch/x86/kernel/ftrace.c > @@ -46,6 +46,7 @@ int ftrace_arch_code_modify_prepare(void) > * ftrace has it set to "read/write". > */ > mutex_lock(&text_mutex); > + __acquire(&text_mutex); > ftrace_poke_late = 1; > return 0; > } > @@ -61,6 +62,7 @@ int ftrace_arch_code_modify_post_process(void) > text_poke_finish(); > ftrace_poke_late = 0; > mutex_unlock(&text_mutex); > + __release(&text_mutex); > return 0; > } >