From nobody Wed Dec 27 03:55:44 2023 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 4T0HqP1WzCz5507D; Wed, 27 Dec 2023 03:55:45 +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 4T0HqP109Kz4c9T; Wed, 27 Dec 2023 03:55:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703649345; 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=jOWsQfKw7h/T9IhLkJ4Ad1wkUgtGg3mR+afEw7JRQis=; b=LnSVzR56UIwJ1MeyxE3beaGJDd8JSqk4v3VjjAHfo8a5P0Zi4Xrkmnso07jHajQ4bZpqbZ XIG4UMPWvlK7RgX0H5IG+yJzFK8KKaWFyc7dB3Jdg1ojKmv/xnKvGN4tVnwxuoQT0PsxJE 0VoW/D3NSEWkmIn6Cp9/Petgqil00N52AwUBUU2wyMgXo+2I3mldlzL9IPF1VpUwv2zteT Nbjro2E+s0RcLX+AGl2M6NhfscPccW5SUQ6REoc4k2TsQqwAnECiIwjf+sVPCS8and1PKo tyEx+36zgjj7JPCui4q2HxUMSa+ifGOg5Bn/7aygd/QgPmiB4wzxLiDHccIChw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703649345; a=rsa-sha256; cv=none; b=Be4xhjhSWJnkq9XoGIPHf7M65DrzXjP27xI6xyvstFxBgwEUOVPRLvcm4H/kk7qw+5tM5e 2sXuP+UTnNcmjrnxrLbJZ/YjeY0y7gd6e3gdGVqJdMFXSktYPWiOlAu9ql+SqXyWCru7fi xZzEI2WjCNpfyzSQ8qTkG9LnmB3ur/jzxASw1+CWSklXon2Pmg0qt+ZEfN8jI5suc0n9Pa +VMlezsT03/TPKi9ioLcqrzIwshnE+5J3nS46KJGdrr4DIc8tHaPGggZDHeHQrGZLhCJbb 2l4e4ynhaHXruXe0hJUK+h9j/Ysi8r//GvgdF5af0n7kQmK49sltVPOpeaFDuQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703649345; 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=jOWsQfKw7h/T9IhLkJ4Ad1wkUgtGg3mR+afEw7JRQis=; b=DIVGBbLl9dWaEGqcMxBeAzMbnF2ibdLMP6nw6jj85XizSJ3sfl94X4201RDdWqcGmIzU8E GX2w5Rwyuszgguy8Vvm8ohgyca9vVAhq2t4duwdWnF159rRbnxqWttdidLhJWaHGswji+h JERRY55nbd2yRsaDxBNyo6uSk3NHMfuTHwlNppzAEbu9Zi3oZ5b+SFWOKv55xuEwZ8dosu 9WUIfbCVHl+9ob2f19O6qLA/y606qt205XIXEz/bDo1/I6SNPOLhTWitz12jsIc4HxVffw qt1bRH6t/ibRjHJkEFkXc3c8wt9cQJFGspi4UUxVc19y7k7mH7Cw8k4FFRVuFg== 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 4T0HqP038yz7tf; Wed, 27 Dec 2023 03:55:45 +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 3BR3tiKO006074; Wed, 27 Dec 2023 03:55:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BR3tip8006071; Wed, 27 Dec 2023 03:55:44 GMT (envelope-from git) Date: Wed, 27 Dec 2023 03:55:44 GMT Message-Id: <202312270355.3BR3tip8006071@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 7bbac6419d17 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 7bbac6419d174c98cc6ea969b68fcfe0f9a9bab8 Auto-Submitted: auto-generated The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=7bbac6419d174c98cc6ea969b68fcfe0f9a9bab8 commit 7bbac6419d174c98cc6ea969b68fcfe0f9a9bab8 Author: Alexander Motin AuthorDate: 2023-12-27 03:30:56 +0000 Commit: Alexander Motin CommitDate: 2023-12-27 03:55:24 +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 --- 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 5650f9d57a01..c4146922edc5 100644 --- a/sys/kern/subr_taskqueue.c +++ b/sys/kern/subr_taskqueue.c @@ -363,8 +363,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); }