Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1189761ybz; Fri, 1 May 2020 16:40:24 -0700 (PDT) X-Google-Smtp-Source: APiQypI3+OCLxFzhti6J9LhvYa6cxjaqnELdHYFnXi3ZNWTFTLLKzdPfoW37gBQzwChyXiXMQfy9 X-Received: by 2002:aa7:d2d0:: with SMTP id k16mr5893758edr.354.1588376424564; Fri, 01 May 2020 16:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588376424; cv=none; d=google.com; s=arc-20160816; b=OjNCMGmHBxD2bTuvP5yX3Y7jWshL3TOuoILHzGSzemcSkhkEk4lGYap9srVslTseS+ Vo1gIz7tgoHnExi3aAwGyFZ3Zif7PRjv7g3gF34HIb11OevnU2/byFEZ4NdXg+LttL+8 7TI5BOPO7vepWj2MtWC4q/QIK1z6MYpN71pn+dBi+hI6+I1+bZOJeJfQmHTGkJVQpcu6 A3k60uC/u8Ycc77jA2qxPqFLt3gSvPvMZqYiefeBxZnY+GSTCiAIVM2vGsC16HR1B6ce 4QeTRnxLfeb+JUGOQ60U4s53odB/YyDFeiHgw4JB1hm3Sb45gq1vm2nWpFAYiRkoSqJv bUlA== 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=L6MCMGNhFZ0yjr03JEat1oro65VbcrGktEtWe2X83Wc=; b=OXQemhYeyl+7uI3neyPlBkUAOR8Br88Wdh1zhnVhYwsus2UfSNrIyP6pRLhuDSz+1S jUGbb//o3outgatjoETJPGOdHlVOAIdMFQFvZbUqJ9NGUcPOryJYEcJtml5xkZbn3qht zrmr7K2DcRI5BeS4oNvw3C2BW/MpDT6DX5GAvMGLuJMBeH0pxv2HItavlwP5xPxhSWTS xPfuYdmKKhN2j5P1gU08HpAjzgquBzW8VRbhy1tnD7O7DRjY6WsXnFQeYqekP0PnDUdX hS6MOHRaiMif3ZZ5YH2YXXuLjapqd89X1FJUoTC29gcH35MkcWp3/3JDFgwWbjL1WYpd N0WQ== 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 y10si2602684ejw.403.2020.05.01.16.39.48; Fri, 01 May 2020 16:40:24 -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 S1726401AbgEAXfG (ORCPT + 99 others); Fri, 1 May 2020 19:35:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:33770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726045AbgEAXfG (ORCPT ); Fri, 1 May 2020 19:35:06 -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 EF055208C3; Fri, 1 May 2020 23:35:03 +0000 (UTC) Date: Fri, 1 May 2020 19:35:02 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: x86@kernel.org, linux-kernel@vger.kernel.org, mhiramat@kernel.org, bristot@redhat.com, jbaron@akamai.com, torvalds@linux-foundation.org, tglx@linutronix.de, mingo@kernel.org, namit@vmware.com, hpa@zytor.com, luto@kernel.org, ard.biesheuvel@linaro.org, jpoimboe@redhat.com, pbonzini@redhat.com, mathieu.desnoyers@efficios.com, "Rafael J. Wysocki" Subject: Re: [PATCH v4 01/18] notifier: Fix broken error handling pattern Message-ID: <20200501193502.7c9b2b10@oasis.local.home> In-Reply-To: <20200501202943.837409514@infradead.org> References: <20200501202849.647891881@infradead.org> <20200501202943.837409514@infradead.org> 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 Fri, 01 May 2020 22:28:50 +0200 Peter Zijlstra wrote: > The current notifiers have the following error handling pattern all > over the place: > > int err, nr; > > err = __foo_notifier_call_chain(&chain, val_up, v, -1, &nr); > if (err & NOTIFIER_STOP_MASK) > __foo_notifier_call_chain(&chain, val_down, v, nr-1, NULL) > > And aside from the endless repetition thereof, it is broken. Consider > blocking notifiers; both calls take and drop the rwsem, this means > that the notifier list can change in between the two calls, making @nr > meaningless. > > Fix this by replacing all the __foo_notifier_call_chain() functions > with foo_notifier_call_chain_robust() that embeds the above pattern, > but ensures it is inside a single lock region. > > Note: I switched atomic_notifier_call_chain_robust() to use > the spinlock, since RCU cannot provide the guarantee > required for the recovery. > > Note: software_resume() error handling was broken afaict. > > Signed-off-by: Peter Zijlstra (Intel) > Acked-by: Rafael J. Wysocki > --- > include/linux/notifier.h | 15 +-- > kernel/cpu_pm.c | 48 ++++-------- > kernel/notifier.c | 144 ++++++++++++++++++++++--------------- > kernel/power/hibernate.c | 26 +++--- > kernel/power/main.c | 8 +- > kernel/power/power.h | 3 > kernel/power/suspend.c | 14 +-- > kernel/power/user.c | 14 +-- > tools/power/pm-graph/sleepgraph.py | 2 > 9 files changed, 141 insertions(+), 133 deletions(-) > This looks like something that can go in outside this series. -- Steve