From nobody Wed Apr 27 15:16:18 2022 X-Original-To: dev-commits-src-branches@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 1938F1AB161D; Wed, 27 Apr 2022 15:16:19 +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 4KpMll0Bpmz3kmt; Wed, 27 Apr 2022 15:16:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651072579; 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=wkpah5l7jHPZ6vx2Vsm+WfPqeDlsn4yfVSQbxpfzX24=; b=ICdYC3AHkZAqLeEDk1aZsOLDAX3z8uqbhw9sWaiHq8oHWbM/+SuCTqC32CyFN/pBFbd2+Q 87xmQUowwz7z5kQ4//+9gGX8k4XTXD0VOvNp0QRgaEJxr8vUcy71C5r4cY7AYY1x4n0U7O dQaFHwDOeg37atI8zZCgmcvuh5jsoh+mT8qyT5dre1rtngjaHo5pmdinX2DxcgelaO3iVu cVYvPG7/i76kXT4nk+C85EdfRKma7mXQvccFUAGXQO86uUPYD5hseeM1rrsX20/TLqGL1P Dmx9LiMHKeKth5lhG2n45ZsSBuEY/9ubhRthO4Yr/Qzk0pfzqLfXQ/T4DyhK4Q== 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 D7D1C26598; Wed, 27 Apr 2022 15:16:18 +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 23RFGIJD007977; Wed, 27 Apr 2022 15:16:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23RFGIll007976; Wed, 27 Apr 2022 15:16:18 GMT (envelope-from git) Date: Wed, 27 Apr 2022 15:16:18 GMT Message-Id: <202204271516.23RFGIll007976@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: 6c25e63c0694 - stable/13 - linuxkpi: Add cond_resched_lock List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 6c25e63c0694482c65e97ddadfd54016d103ef31 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651072579; 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=wkpah5l7jHPZ6vx2Vsm+WfPqeDlsn4yfVSQbxpfzX24=; b=wWpIkogDhJ3qY1I7KoZWlsABactPUm3sRz9SZVgN8Y8DEGFTV6SHQfh4FtYum3qRMzN75x 72UhPo/rR1qVC5WkU+L5WJS8u9cN4l4FViIDebaJe8HSTp77qCkdiGIIH+5eIMAet07MKn snRDIacLwVDOOOPec2kwRv4YxP8XAOvAplr31+pcKM0U46mcqebu66R2/WdTJm+EcPQUH7 JcYhqgdXEx/uvcFpUkogJ+kRBOn+y5KspIckfihfNe91txLOhokbbackN2QP0ElCN7+dQP xX/J2oAiSyjBZpwagqzKEZqrDYgknOcZhXdLyRR3mU3gsTwwp5ZksMMcWvcfDg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651072579; a=rsa-sha256; cv=none; b=gitatFF3ubUZw+eWaV1D6seSES9TCe7bO0nT2NT63Lf8dgKFQ5ThlPTdRBCUtCiVA15xLe evqJ4kL618I/VcUx9roXk1QlVux4/xrSCXyJdPpfcLk/dN1W0WocrvDrDWYgqzLIEFwfDp C6UcMuruQukuB2H4LD3EN6zoAUVIdrih7+Z9Cze5mHej3D/FbAiz/PGAIKCGIHtEpmnGr9 Imlsf0XNKUaktgeTCY0QDzVeU6iXzlBPvq2kDdezUUa5QCGeIGmlh2W6FO9mv3daExFosH BJfIEeAZzqmkB4v11uAHItunsBkys7OxW2xEpx9VGxPlduSMrN7zioMD/GEaQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=6c25e63c0694482c65e97ddadfd54016d103ef31 commit 6c25e63c0694482c65e97ddadfd54016d103ef31 Author: Emmanuel Vadot AuthorDate: 2022-03-21 10:14:05 +0000 Commit: Emmanuel Vadot CommitDate: 2022-04-27 16:34:47 +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 (cherry picked from commit 9b8016548ef61e2c42271c7dce35d0322540d2f1) --- 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 d003d12ec89e..4ad95446301f 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 @@ -126,6 +127,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);