From nobody Fri Jan 19 16:35:24 2024 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 4TGlbJ4h2bz56rqW; Fri, 19 Jan 2024 16:35:24 +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 4TGlbJ3sv0z45w6; Fri, 19 Jan 2024 16:35:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705682124; 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=HkiTdXmVr9PhOuqTW4id5037MvmhwUJN/UXN0ZbOlD0=; b=TvaS3MNhV6HEpeSot7WP0m+Vn33NszMUbSxrIi47MMb8wHvRqGYen1bbQ4ZEdA1gti6Mrz uA3i+3RWMriCxis1L3R0+RtCOM5JL4hDxQ2yyQw2gD+jyTIsZFkKQb3kSZ3Cw7TSPfHjUa IkHRr6bBU10uFXBmukBpwYfPkNHoC3u4FrDCxOy2C1erTJr5K930YsCyA2BwFyCX4P+PSV vR07M0Zh4yZLf5p6J2KY7Q5CQrSI6oszx21TXcJlsx1Uq/zr/RpZ0nOK/tUbX0+DtKJR6L 5WRYRn7C4Huww8+gkopgFCNEfsjb96LELVBswRMvs6Gronwm02b3x41Jcer6jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705682124; 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=HkiTdXmVr9PhOuqTW4id5037MvmhwUJN/UXN0ZbOlD0=; b=EB0wDQNuoNtzAa0Lz8ZZTFaFG/TuLu8gDCvq2H4DXvK/DWjmB6MB8ZV/R8SslKCK7NY2Tc FNLkns+QBjBcSOtH4u/qyS+SQrcT7x+iVL3mBP5I0eCH/oqUNbMaXdMvdkL0ccMG42m9EL 0BeWGNWDIqo3bqKEa4JqEK4klRIvcPz7mwqI6+426mOn6/bf+ZC+KobATXpd6w4Zrp73qL y5GJjWMY8KpbSlHAl0fV9E4CkQ2GIgDKlKmNmbkejIlpUqd2pq2J2hUp8R5JdfiBRqsN0N QazwPNuH18/isxBsb+klhox0ZQVeY0fvqRKV94ZuIJqUmm2T07liUU64COtQ8Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705682124; a=rsa-sha256; cv=none; b=ajYXY++41kMp9i1qfaxlEdvAdslq3NG+Ce/tRh5RPl1h/YLyBA0+E9c2L+R6+VWSCjvtZ9 ceX0Dn21DE1SRD1fJx7qTKQOQy7CeeEFlXuB/adg3495gsMpv84T1QBDJeRoL5U5AazBCa jewj2H6HvatK0HK1dUclpiJEi8Rwkp5fSlkrJOV95m5H6W40AfokrskxfvhUCQGX9qoWZp TvqlcrT21l3sO+fdvCoSrPyHmOpnVaKTuSt0inTMW1Hk5CD7ss7dWdCYf1oTb8tvW0RikY kFPC6sRtvLgPPFjmatXe76labcZf9hYbsXvrHYIiON8WKGBtDN8NEI1JHQaKPA== 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 4TGlbJ2wcWzymJ; Fri, 19 Jan 2024 16:35:24 +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 40JGZOsr026314; Fri, 19 Jan 2024 16:35:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40JGZORS026311; Fri, 19 Jan 2024 16:35:24 GMT (envelope-from git) Date: Fri, 19 Jan 2024 16:35:24 GMT Message-Id: <202401191635.40JGZORS026311@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: c849f305614c - stable/13 - Schedule fast taskqueue callouts on right CPU. 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: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c849f305614c51b9c71196012596266fb661c54c Auto-Submitted: auto-generated The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=c849f305614c51b9c71196012596266fb661c54c commit c849f305614c51b9c71196012596266fb661c54c Author: Alexander Motin AuthorDate: 2023-12-27 03:30:56 +0000 Commit: Alexander Motin CommitDate: 2024-01-19 16:25:17 +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); }