Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4545492rdb; Fri, 29 Dec 2023 05:37:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcTJH8eijrnwlKlZf6aUSMXXHvHd+VVSxw8DQr+6uH3jM+FuuGCPrGgsgeMgVAGpblBmrI X-Received: by 2002:a05:6830:926:b0:6dc:654:b4af with SMTP id v38-20020a056830092600b006dc0654b4afmr4142928ott.18.1703857078046; Fri, 29 Dec 2023 05:37:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703857078; cv=none; d=google.com; s=arc-20160816; b=EYeIQe5BtyzFC4LiY2FWabsgG7Ig7knqZ+4ywdmHhw3RZ0ihgb5wEShN4cLH5PSu9z eQpbNGs+dBNjHNm3Xd9DBrcttGMYYHgoBCPwIyrtNaH+3a7nh52OYyyWhJT7ebqC0K84 x+LySxytBhcvNVQ2GB4jhE5AZvd8cU9VwM3eHV0J9y98GV37vJ0XUqU8I1lBnCqWCDXa YVtlNBkqUuL6niJ+K/QdNPlgViBMCKXgRkGPTQrUEugw9BtL0sjZ0VHJXBg9+jtU8w1o ho426V1bksi2mqICEuLStojhEsc+63JiFUB0+jPaYCsZ8ncldHHTQdPAm30ny/3iW5de FhNg== 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=drT8s+9Lo4+5xk7ZxtQR2sSrDLvVgTHuFaCMfu3pdag=; fh=jxebyrsJ6pPMnKFIzO51L5XPcKWl4d3RvF7zbfjTNVE=; b=u+A+bUazKxbBaTO6HjFMDM6pybhIpnLNpyh9wSUm4H9lmUugU7L5Uy5BwzYXrG5+u/ WKb7HjIOE2zvcGo2ywtD7g+6tsSrg+qJenzHFp9COlnXCKvkjLkr+TW6X23fprZyieG4 jsM5szBgghxCBePO9pFHRNINJdslbIHt54zaFP0x5fk9vU8XSFOHEnOaGtRebW4UX2tb Uivc9ptiohIYnuzZNWTMldivNlDH7hLoxdwB/AQUPN4Jg5egBOgA5tyiXzxGFnPduwVQ bWmF/z5+O2jbzRHLI/MbQlaek59o8AvzhXnwb/6elM48di7JmhxJpPs9mGO6I9FcqdpO klwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13101-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13101-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. [139.178.88.99]) by mx.google.com with ESMTPS id d4-20020a654244000000b005cdf89f64f8si12188560pgq.99.2023.12.29.05.37.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 05:37:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13101-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13101-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13101-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 A3A3A283703 for ; Fri, 29 Dec 2023 13:37:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A065211715; Fri, 29 Dec 2023 13:37:50 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (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 B7B0D11C89; Fri, 29 Dec 2023 13:37:48 +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-f43.google.com with SMTP id 46e09a7af769-6dbb09061c0so702450a34.0; Fri, 29 Dec 2023 05:37:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703857067; x=1704461867; 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=drT8s+9Lo4+5xk7ZxtQR2sSrDLvVgTHuFaCMfu3pdag=; b=jjjdrYmlt83Gxk3/lJbyEgIGy5auA5McVadTlVL3n4SJQqq95Eo5/TzyxkZB0TI2lE Z3SzGkvNGiG6cSMiH9xFsD8QcuqP/5MiP8rJt+ftWRxPaCtElntDIPRM796ODSz48l0j y+g++xfj2M+QTmQuQ7aWdxXm3FuZ9PMKdCK+5O35x60JNnGWk2Zhbp4nMpUaeZzg4soQ OjxHh8Yb7vAIOw3UyMFi/beCZRmJN6Z04ElIT7GLxLDlw4bDE4sMiccN9iT4tpe+G+h/ m5xHJ9NQft4R04hvEB534sfzV29BaVnTarQ/qp3CblNRuC+16r5L3URwbef6s34/0JbU S/DA== X-Gm-Message-State: AOJu0YwS3u/Lk0dKXGLTWFFPtorC8bqiHBxgtErDtHxOg87Fh91Mlqxj wHHpv5xXNGHLk6KcK1EqnpjEebzl5iiCL9SIr24= X-Received: by 2002:a05:6820:2801:b0:594:cb36:b255 with SMTP id dm1-20020a056820280100b00594cb36b255mr7180554oob.1.1703857067610; Fri, 29 Dec 2023 05:37:47 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <5754861.DvuYhMxLoT@kreacher> <6019796.lOV4Wx5bFT@kreacher> <4874693.GXAFRqVoOG@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 29 Dec 2023 14:37:36 +0100 Message-ID: Subject: Re: [PATCH v1 2/3] async: Introduce async_schedule_dev_nocall() To: Stanislaw Gruszka Cc: "Rafael J. Wysocki" , Greg KH , linux-pm@vger.kernel.org, Youngmin Nam , rafael@kernel.org, linux-kernel@vger.kernel.org, d7271.choe@samsung.com, janghyuck.kim@samsung.com, hyesoo.yu@samsung.com, Alan Stern , Ulf Hansson Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 29, 2023 at 8:02=E2=80=AFAM Stanislaw Gruszka wrote: > > On Wed, Dec 27, 2023 at 09:38:23PM +0100, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > In preparation for subsequent changes, introduce a specialized variant > > of async_schedule_dev() that will not invoke the argument function > > synchronously when it cannot be scheduled for asynchronous execution. > > > > The new function, async_schedule_dev_nocall(), will be used for fixing > > possible deadlocks in the system-wide power management core code. > > > > Signed-off-by: Rafael J. Wysocki > > --- > > drivers/base/power/main.c | 12 ++++++++---- > > include/linux/async.h | 2 ++ > > kernel/async.c | 29 +++++++++++++++++++++++++++++ > > 3 files changed, 39 insertions(+), 4 deletions(-) > > > > Index: linux-pm/kernel/async.c > > =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/kernel/async.c > > +++ linux-pm/kernel/async.c > > @@ -244,6 +244,35 @@ async_cookie_t async_schedule_node(async > > EXPORT_SYMBOL_GPL(async_schedule_node); > > > > /** > > + * async_schedule_dev_nocall - A simplified variant of async_schedule_= dev() > > + * @func: function to execute asynchronously > > + * @dev: device argument to be passed to function > > + * > > + * @dev is used as both the argument for the function and to provide N= UMA > > + * context for where to run the function. > > + * > > + * If the asynchronous execution of @func is scheduled successfully, r= eturn > > + * true. Otherwise, do nothing and return false, unlike async_schedule= _dev() > > + * that will run the function synchronously then. > > + */ > > +bool async_schedule_dev_nocall(async_func_t func, struct device *dev) > > +{ > > + struct async_entry *entry; > > + > > + entry =3D kzalloc(sizeof(struct async_entry), GFP_KERNEL); > > Is GFP_KERNEL intended here ? Yes, it is. PM will be the only user of this, at least for now, and it all runs in process context. > I think it's not safe since will > be called from device_resume_noirq() . device_resume_noirq() runs in process context too. The name is somewhat confusing (sorry about that) and it means that hardirq handlers (for the majority of IRQs) don't run in that resume phase, but interrupts are enabled locally on all CPUs (this is required for wakeup handling, among other things).