Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp691398ybg; Mon, 1 Jun 2020 11:48:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4d+nKPfMTkc94tdWi4cY9OViM1UiTDAUIVVgKapfyoOLbzsY8FdKHLU9y3b7yrjrWez9K X-Received: by 2002:a05:6402:3c1:: with SMTP id t1mr23651983edw.350.1591037303209; Mon, 01 Jun 2020 11:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591037303; cv=none; d=google.com; s=arc-20160816; b=JBcHK9qaomHI5GPX9veJKjkWuXbnzJThghkTzUg5w/P6JNmk1yvrphOQCt8W7Twld7 NH1gxUpW1sJmzzW3PL+CF00cZ39rSkuLveyXwgUtaTlJ20etq7HSptKsPiNgyvyB180b Abl5hXp/y3h4gOO8pwO/GF71aeWgx7uFLH2CT8Ki/0PrzCysC2dUjhn3JFeFDAoCo4M8 G6c4brrHq1+G+t/Y64g2+zTVRFgNAEBQSaySBo2TGwRr5rPbQt2/Je05RRi4LwPGI6Kl D5zXexGJ7ykfWbesvRm7BuJLQ4/9oWAUzrzynwLzptP+ExEWTN5OZGbXnNFOu97KjgT0 6dBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=WpZyj796ryAXOy5jG9QU2yR5Ej+vR4ZGFFVDCYg9LOs=; b=lJSyxwR2czIuF7H5A0xjW9wSys2iUx+I8IaVNpR09urnW9J+f9uJDWXHgXaayTz6bG aPnY5W9ZdzkSheMNxEQPr8nFUGz01AlYEvkYqho7g7ubvHj1XwmYElCUOv5V79FH3hMD mikN2l7vqFv3gCCGTym/+zKTYutfVImE+Vd50pe8PhourRlnkfmDWWjrbGCSc4q0NGaw i7Kf3UWg+YQfHRt8V0atyn9meLlEUlijy2jcBtVmMYMeY/pB5koPh3B2yKi8VOvYvCRD mNflYnL5w21hWdqrYb71/vy0mARo1YcrvqOsHFlbv71ignFgH9w2SL2tTnrVxKE2s+Az JRAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hzo7RFzn; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt26si171686ejb.750.2020.06.01.11.47.59; Mon, 01 Jun 2020 11:48:23 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hzo7RFzn; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730819AbgFASqS (ORCPT + 99 others); Mon, 1 Jun 2020 14:46:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730228AbgFASqQ (ORCPT ); Mon, 1 Jun 2020 14:46:16 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECDBFC03E96B for ; Mon, 1 Jun 2020 11:46:15 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id f5so563986wmh.2 for ; Mon, 01 Jun 2020 11:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WpZyj796ryAXOy5jG9QU2yR5Ej+vR4ZGFFVDCYg9LOs=; b=hzo7RFznw6P4fV7/+dxSJ16wEpI7L5zZ8rska4xe7o0vhife9k7JzwqaqQNwIJN+ZS 9M/h57JJi3FKMApsvFEok8PAniX17hi76Op9oGATsgnFm3aIkng6gRUCasQVcsFJM9nh MNOzhFRNZoNGhI684Xoey38LdlBoex0yF4TNQML6+nKeFA2XvGhsloa8A/fykHf1nrKG SSslbeKRRvAqBt2mcRo/dyKcsqhpr97lj/6xXFNkvY9TV8koGH6pkAEHom6a8wdx9OJa 9HclkizEh6jkU1qNr+kPUxuuW8BcX0hr8GtkyB2wkZbGU9T6Dl/5pjyRHcuzyPsnHDYt vHag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WpZyj796ryAXOy5jG9QU2yR5Ej+vR4ZGFFVDCYg9LOs=; b=fd5HneIzOBs3q3j3/+elv2h9qi6zROt7mq95MiYFMxam9btOU4e5JumgP2QL3axvRn Yk4SgPtfQept5KXVOmpuIblplPOxAISPzB4Hi5tjPbHsrOO6F53G+hhWPKsZYQob5KUY UWwLLgrnUCz6BM+BcOX9rW9apxP/W8K32zMnxnDusDpqrQKbc7kceaf0twf7QkLTYoWb edwqTxstiK2EZ8ZfjgH1wMoRoOPpBxSXYQg72KVga6pQac7v9grwAT+pPmMIIlqHFxhr 9hZ45JxNfhib/xs6E4Svru7vj9WphJFl8hPD45SrIUX8nSd4YVFWQ263ijyCvOXMs7Sb NzBQ== X-Gm-Message-State: AOAM533oDyVOm5sNwu5Z6m/Iq0V92dUnM67tqjl7SM51j55lVmuKmfeu szdYu5R8oCslhbqqsty1GDMN0FPz6++v X-Received: by 2002:a1c:b155:: with SMTP id a82mr595760wmf.46.1591037174401; Mon, 01 Jun 2020 11:46:14 -0700 (PDT) Received: from earth3.lan (host-92-15-172-76.as43234.net. [92.15.172.76]) by smtp.googlemail.com with ESMTPSA id 23sm302229wmg.10.2020.06.01.11.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 11:46:13 -0700 (PDT) From: Jules Irenge To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, paulmck@kernel.org, mingo@redhat.com, boqun.feng@gmail.com, Jules Irenge , Steven Rostedt , Borislav Petkov , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "H. Peter Anvin" Subject: [PATCH 4/5] x86/ftrace: Add annotations for ftrace_arch_code_modify_prepare() and ftrace_arch_code_modify_post_process() Date: Mon, 1 Jun 2020 19:45:51 +0100 Message-Id: <20200601184552.23128-5-jbi.octave@gmail.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200601184552.23128-1-jbi.octave@gmail.com> References: <20200601184552.23128-1-jbi.octave@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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; } -- 2.18.2