From nobody Wed Mar 23 13:38:59 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3AB6B1A2A97F; Wed, 23 Mar 2022 13:39:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KNqFc17Y2z4TTZ; Wed, 23 Mar 2022 13:39:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648042740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CnHH/1gqH5GHPoIsf6AJTvTyfMJWVcajYM9M9Jhemcc=; b=OYV8O2kPriaeLmOqdqAJvi7t2R05SI6y6EgA0OOA4C28aU/JMmFiaIrxDiB1W5cttg8SeY NUr93bl+YKlkrNbvq7UHsgAGuDAWqqUt/V4rJSVgZE2PqJSyTfc9lOdHRy9/y+vBRFMRWC PIdnqg3JVnuCLRup8ytqx4+YxH2i+mOrMMmLq7Q4//XyZgKtu3HYcryY1soYPvHK/TbUsa /Eu9l39e+TZ6Utmg+KdDRLkiAWRiuPuzImo1VqYzNrNrBzNcOz8nWPZjPeetiCN56JiOBA P1M6bzAQ6iURvacvwvAZcKMUcGxSWWJcBLN2AGG2rP8s2dPSSfDuw+huW/OYFQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 01F622445B; Wed, 23 Mar 2022 13:39:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22NDcxeG006952; Wed, 23 Mar 2022 13:38:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22NDcxd1006951; Wed, 23 Mar 2022 13:38:59 GMT (envelope-from git) Date: Wed, 23 Mar 2022 13:38:59 GMT Message-Id: <202203231338.22NDcxd1006951@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 9b8016548ef6 - main - linuxkpi: Add cond_resched_lock List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9b8016548ef61e2c42271c7dce35d0322540d2f1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648042740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CnHH/1gqH5GHPoIsf6AJTvTyfMJWVcajYM9M9Jhemcc=; b=R176kDJ5+ewI+anIlxDvEF9951FccamzajKH8mMjSbbFNemeP9SJzJ/eDtp7C6X1W98ZYf /lZ/eVGwSjlKdxdimSD0zjqhWgyx35R2GfQtIV4nC1OnnTK6DPCzeTmwzPODNaBnAY7nsd h2LwntEzcqmBDt+rFsIfFDtUVvTkQGS4P/go+ujU/6J3REebUe6mOJt3vCYP8OiaxDAiH1 90hqorweZK5AkqPwQIES3l1jD6cfseseweJ7p+WoJfmoWKbNU7TYsU89JcmLpN/f7P20/A 1oVgpfkXI86Isb58e7KSXrjOk1ZGuS9yC5XxW+GENbgmf5pVL63DZd4y4nef8w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648042740; a=rsa-sha256; cv=none; b=XC/xcTyR7PstTkI6k5IR/2E1z75cyJ8pJA1a2lx4nBn19rQzf0DrsAkBfRNkUudWdPC05g m9vG935YalRaD4ypVQXbQjvoa6DJR24utGeADz1JMcfdM5WCX/Qh8Cx6CTbQs6/iZ5ciRI urGLPQ0E/AwuL7VbUFyouUIlSawYJSWuMydlaDEnLbs/IPaxecE/VWEIMBlpqTBWvuS0ku vNg8Bl7qsair1AOIxfffqJ5evbCEEH+yDXMmj1+nZkRh84QXxiZP5E5lhYiPuDydMTVc4r oc5nfzGRLEqpjf9aN3kDqrTE9E0uHVSdmipbmuICawV2vGEcduwX02u7kffqrg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=9b8016548ef61e2c42271c7dce35d0322540d2f1 commit 9b8016548ef61e2c42271c7dce35d0322540d2f1 Author: Emmanuel Vadot AuthorDate: 2022-03-21 10:14:05 +0000 Commit: Emmanuel Vadot CommitDate: 2022-03-23 13:36:55 +0000 linuxkpi: Add cond_resched_lock If we need to resched it takes the lock, resched, release the lock and returns 1, otherwise simply returns 0. Needed by drm v5.9 MFC after: 1 month Reviewed by: hselasky Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D34620 --- sys/compat/linuxkpi/common/include/linux/sched.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/sched.h b/sys/compat/linuxkpi/common/include/linux/sched.h index 5bb9047640b8..aa4bdbc65c5b 100644 --- a/sys/compat/linuxkpi/common/include/linux/sched.h +++ b/sys/compat/linuxkpi/common/include/linux/sched.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -127,6 +128,18 @@ put_task_struct(struct task_struct *task) #define need_resched() (curthread->td_flags & TDF_NEEDRESCHED) +static inline int +cond_resched_lock(spinlock_t *lock) +{ + + if (need_resched() == 0) + return (0); + spin_lock(lock); + cond_resched(); + spin_unlock(lock); + return (1); +} + bool linux_signal_pending(struct task_struct *task); bool linux_fatal_signal_pending(struct task_struct *task); bool linux_signal_pending_state(long state, struct task_struct *task);