Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp948064rdd; Wed, 10 Jan 2024 04:33:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5jpvp0VaAOryVIVdZE9Y+/lMV4++zeS04Cb/2dDGkM53BOdk7OmAGG8wZQA/kd85yBTwk X-Received: by 2002:a05:6a20:938d:b0:199:4383:8566 with SMTP id x13-20020a056a20938d00b0019943838566mr684084pzh.77.1704890011676; Wed, 10 Jan 2024 04:33:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704890011; cv=none; d=google.com; s=arc-20160816; b=H+zhfTstHJ6kdOTCwiA+RzIuMwJYW4kXiwM8mcmr7CawAAhIdEw/btneZ/8BXh9Fn6 oIUfTIqBu/myxcQcKGxKZnoEyAdVW4lzIOq8v+PYe9yE7cBg6sxtNia6YeHCfZi1Ce8W SDAS4frKABynjGRqladroHwEZn07WO62+FkJVgt8BeStqKQG5P+hsf+bHFXWfwM+b2eO QKwdKdnznRiDj5QsCEPJc2t+xqNLYdqe2vZc04oXP+1saZtq64FFI1LI9IAhZ4kATs42 zVXVOooKe3IXwKsX3/aeVeHV1YaZ1uGvIpDhsPBXdkYaWvf0qbWB2V0hs/d2I8c7Kr5W L6Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=mdVwVLgR6l9w9IUJl5rXBB1+lz8z25YXeBpy/UgGLXk=; fh=Ku/KJoiNMSG5YhW4UgTRPjvnVOuVJuOm3WLKHDZFOK8=; b=wJhwciOdnOiso8KAXN8y3FwrNDysi/JBrjFJ5llxHD/zFJ87WG9qcWdXQI1jo4Xf1T KGCnqEzcpg8r1Vayg6FBGI8dzKJT5bHkFXF2BUxEUHIMa7hPqp4zU36rn2wIPNW71YJO /EGxFAwA2UmdM0olpRaeOv3vGyg96JzDAjzIGg2852EKzh6mOkoJdtvD6QfjV3n7/m5n CE+wBtZRpaV9zb5nkskxu4sghXpeeJSN54e7PDuMxMZ8vKq3ZHYlEZYPN1ZCMVXxQk+C uh0hyGYmPd7UzoGU46tBpHWwGAFgxxrOt9QzU16sVkS/VrX+66dEMKjMxUe9hSXX+TZX L52A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-22172-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id pl4-20020a17090b268400b0028c68d1b85bsi1392070pjb.19.2024.01.10.04.33.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 04:33:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22172-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-22172-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 52D32286BB8 for ; Wed, 10 Jan 2024 12:33:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E07446430; Wed, 10 Jan 2024 12:33:23 +0000 (UTC) Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A25B848780; Wed, 10 Jan 2024 12:33:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-6ddec302e68so222551a34.0; Wed, 10 Jan 2024 04:33:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704890000; x=1705494800; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mdVwVLgR6l9w9IUJl5rXBB1+lz8z25YXeBpy/UgGLXk=; b=sOeUVJh6BzF99F1fRi7w/Xf1tW2GrpDg/t3sVSKSs716k7HmxnAgU4ncmH9Kgtg4SU t6Z3nQ3NTxNzRi6iR0JKzeZSX63n2vWevzFNP5fjKo5FwFIQDKZ87XchwyAf368rw3E8 X8hsq6j6OHRomhRJB6QqL6xynX7EyJqVaxIoI5yTWTowrV1OSmRdre8ALgnuDPcnfnKA wcLp0u6kK88tOFgI2tMOXgVwvkYR6UC5SCip/os6Cl6IZ83vjhzuL9J169T1Bh8qqy09 AZOT/gS3i93cE/wWxdePj2lCq0umI+kfPceXNq1nIEXd83hzLqn5vJNXULgVPUVuECpB Jqpw== X-Gm-Message-State: AOJu0Yzzm5ZjUkJkX6lrZYXjAC43uBAHtp5VL+2aBEgZNYRMXraWjvat qtmhdLW6H1tUVB2w+R54YwSU/4rmEgqHE8/cUh4FDzgY X-Received: by 2002:a05:6820:2e02:b0:598:9a35:71f1 with SMTP id ec2-20020a0568202e0200b005989a3571f1mr1216376oob.0.1704889999119; Wed, 10 Jan 2024 04:33:19 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <10423008.nUPlyArG6x@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Wed, 10 Jan 2024 13:33:07 +0100 Message-ID: Subject: Re: [PATCH v1] PM: sleep: Restore asynchronous device resume optimization To: Stanislaw Gruszka Cc: "Rafael J. Wysocki" , Linux PM , Ulf Hansson , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 10, 2024 at 11:37=E2=80=AFAM Stanislaw Gruszka wrote: > > On Tue, Jan 09, 2024 at 05:59:22PM +0100, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > Before commit 7839d0078e0d ("PM: sleep: Fix possible deadlocks in core > > system-wide PM code"), the resume of devices that were allowed to resum= e > > asynchronously was scheduled before starting the resume of the other > > devices, so the former did not have to wait for the latter unless > > functional dependencies were present. > > > > Commit 7839d0078e0d removed that optimization in order to address a > > correctness issue, but it can be restored with the help of a new device > > power management flag, so do that now. > > > > Signed-off-by: Rafael J. Wysocki > > --- > > > > I said I'd probably do this in 6.9, but then I thought more about it > > and now I think it would be nice to have 6.8-rc1 without a suspend > > performance regression and the change is relatively straightforward, > > so here it goes. > > > > --- > > drivers/base/power/main.c | 117 +++++++++++++++++++++++++------------= --------- > > include/linux/pm.h | 1 > > 2 files changed, 65 insertions(+), 53 deletions(-) > > > > Index: linux-pm/include/linux/pm.h > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- linux-pm.orig/include/linux/pm.h > > +++ linux-pm/include/linux/pm.h > > @@ -681,6 +681,7 @@ struct dev_pm_info { > > bool wakeup_path:1; > > bool syscore:1; > > bool no_pm_callbacks:1; /* Owned by the P= M core */ > > + bool in_progress:1; /* Owned by the PM core *= / > > unsigned int must_resume:1; /* Owned by the PM core *= / > > unsigned int may_skip_resume:1; /* Set by subsyst= ems */ > > Not related to the patch, just question: why some types here are > unsigned int :1 others bool :1 ? No particular reason. I think I will change them all to bool in the future. > > * dpm_resume_early - Execute "early resume" callbacks for all devices= . > > * @state: PM transition of the system being carried out. > > @@ -845,18 +845,28 @@ void dpm_resume_early(pm_message_t state > > mutex_lock(&dpm_list_mtx); > > pm_transition =3D state; > > > > + /* > > + * Trigger the resume of "async" devices upfront so they don't ha= ve to > > + * wait for the "non-async" ones they don't depend on. > > + */ > > + list_for_each_entry(dev, &dpm_late_early_list, power.entry) > > + dpm_async_fn(dev, async_resume_early); > > + > > while (!list_empty(&dpm_late_early_list)) { > > dev =3D to_device(dpm_late_early_list.next); > > - get_device(dev); > > list_move_tail(&dev->power.entry, &dpm_suspended_list); > > > > - mutex_unlock(&dpm_list_mtx); > > + if (!dev->power.in_progress) { > > I would consider different naming just to make clear this > is regarding async call, in_progress looks too generic for me. OK, what about async_in_progress? > Fine if you think otherwise, in general patch LGTM: > > Reviewed-by: Stanislaw Gruszka Thanks!