From nobody Fri Jan 19 16:24:39 2024 X-Original-To: dev-commits-src-all@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 4TGlLw1hZpz56qV9; Fri, 19 Jan 2024 16:24:40 +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 4TGlLw0fsfz43P7; Fri, 19 Jan 2024 16:24:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705681480; 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=htrNR5uiIk7rq5QI+9jsrWf0YtRuL5vS3juqPCrYo6o=; b=qCDqUQ6l6hJfZgBKrmPqFTcHhCxP+QhdFijWmw/5Yqt8WdltZIxAlKeVLYKGQ/BiLeHpJZ gKUQIGo/ilCzimQSRW5IGK43cmt+aZ4BMPXvjRyAAf+L7F8vD07V0XaQznqNu20UxAC5sW HEzyJFp2g8Ketfh6dZlVzlW9pBrEcMqaEySN+DMb/W0KO5u8GCRZLjmygAuTyFLQfdNadJ OoQefTBUjlWkatDARWOjYR4ihFYHwZ2sldimLUPooEKFEcP2bGPDpHmohFFBdXNy08x8j1 aOfIB54M6IUTJbofxARy2pMcO1q6JMfcu8oNSBtdgqxF5JIMoqc0C43C7Fm1eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705681480; 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=htrNR5uiIk7rq5QI+9jsrWf0YtRuL5vS3juqPCrYo6o=; b=j2LUoi26vLm9larGt2Eh5zwKEreRgUn3tm9OhLMRmHf0L+th79e3Aw2F1iSlKUIA06GHbJ BruTAgyGXRz/qrZpO3cMxcOPyYEgbKyMKYu5Uj3ilDOFTQegrJ/Az84TVYHQeVoxoUfmVi eRunTpG+pkBu6LxK8dKJNjXgo9Yh9uzYPWaqVQyuLUQbMqBJtPT6rdmWSaYKt52gx4l7KI +rFZMZjVSc7mMMvMy/HRLONw3MvU+MNgduD97M3NrGdZUEVvjWo9qbjE0eckyKedzQExFw 8O9XBxOO9EF03XTEtwSnpOWVR5aEwvIQqDqzyvS0imJZtMa2wAeqvdXfFpHydw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705681480; a=rsa-sha256; cv=none; b=mMtwPYaRrrJq09GnNbKTMBKd6V4pPkvOPup2XdsAg/MCrxSOX55kvxaKK+PQyxfp64BAIZ FwPE3kYrCRuhQ4q1EcBG1TVMmcf4UhAyDFi/sJeoQVWojLN9JjuSf2kgF4GdUQhT3k9a9I GKUHc6cKGs4UXzX+bEKBDCY/iDobBYEy+XTdi9gom77oJg9k5XCNuYxx8w0W36Adf7rORV cnT56xThfda7aOD85w6Z1fsTQOD148/EiDRGGQxq7JXuxPJBZqiC6pySLKP3kiaDxhDac3 02jZ5hb4yJFBGsoussxtx4zuWixiboWkU2jnICPGk2TeBy3KiLhPpkiZvGudBQ== 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 4TGlLv6qltzyW4; Fri, 19 Jan 2024 16:24:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40JGOdbp009103; Fri, 19 Jan 2024 16:24:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40JGOdJx009100; Fri, 19 Jan 2024 16:24:39 GMT (envelope-from git) Date: Fri, 19 Jan 2024 16:24:39 GMT Message-Id: <202401191624.40JGOdJx009100@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: faf11e40b49a - stable/14 - Schedule fast taskqueue callouts on right CPU. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: faf11e40b49aaa44a553df781d2716ae849bfc56 Auto-Submitted: auto-generated The branch stable/14 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=faf11e40b49aaa44a553df781d2716ae849bfc56 commit faf11e40b49aaa44a553df781d2716ae849bfc56 Author: Alexander Motin AuthorDate: 2023-12-27 03:30:56 +0000 Commit: Alexander Motin CommitDate: 2024-01-19 16:24:35 +0000 Schedule fast taskqueue callouts on right CPU. With fast taskqueues using direct callouts we can reduce number of CPU wakeups by scheduling callout on current CPU if taskqueue calls taskqueue_enqueue_timeout() on itself. The trick won't work for regular taskqueues, since the callout thread will occupy the CPU. It also may not work in case of multiple threads since we do not know which thread will pick the task, and we do not want excessive callout migrations. So we optimize only the other cases we can. In practice this allows iichid(4) taskqueue to stay on CPU where underlying ig4(4) interrupts are routed and to not kick CPU 0 with timer interrupts on each sampling period (every 2nd/3rd sleep). MFC after: 1 month (cherry picked from commit 7bbac6419d174c98cc6ea969b68fcfe0f9a9bab8) --- sys/kern/subr_taskqueue.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c index 07323763204d..832f120e5d82 100644 --- a/sys/kern/subr_taskqueue.c +++ b/sys/kern/subr_taskqueue.c @@ -364,8 +364,14 @@ taskqueue_enqueue_timeout_sbt(struct taskqueue *queue, if (sbt > 0) { if (queue->tq_spin) flags |= C_DIRECT_EXEC; - callout_reset_sbt(&timeout_task->c, sbt, pr, - taskqueue_timeout_func, timeout_task, flags); + if (queue->tq_spin && queue->tq_tcount == 1 && + queue->tq_threads[0] == curthread) { + callout_reset_sbt_curcpu(&timeout_task->c, sbt, pr, + taskqueue_timeout_func, timeout_task, flags); + } else { + callout_reset_sbt(&timeout_task->c, sbt, pr, + taskqueue_timeout_func, timeout_task, flags); + } } TQ_UNLOCK(queue); }