From nobody Mon Jul 25 13:54:56 2022 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 4Ls1km6DgVz4XXyN; Mon, 25 Jul 2022 13:54:56 +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 4Ls1km5kfVz4Lnh; Mon, 25 Jul 2022 13:54:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658757296; 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=hiLag6aJnVyWgdgFPq79Rhbos3I60Y/kq53WdmQ/SZM=; b=VYhM7rJYwM8ffBE1uvJclQoTJnoyP3h62qEol/kHd8/0wPHlg2SJEGXDxCUpleDahYR2dk kNa1K1vIJUY0HaCic0VDOgw3DGBXrPmx9XGVIawK/FG+HIcuabStxcr+tH3OwfBPqtVAjI hDo6NwLLaN+8au/ICnF+OQfMJwmekojrmFReyhM1HrJTPsg1Pjsu/5XNrbn2a6VX8x0Am/ s3+fYFj8dc9fJzzwqpHggd3I2ObKd8xf4m5d1aiGIQVa+opH6X8KVhp3yti2olgx0PRRfw 6Z6uAvqR1ejy/yobXGqrT2yIhuLCZ89qcxx0bGuYKi9QeuXk2zAfqdzkTi1+VQ== 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 4Ls1km4rKgz10Yj; Mon, 25 Jul 2022 13:54:56 +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 26PDsusw019848; Mon, 25 Jul 2022 13:54:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26PDsuUB019847; Mon, 25 Jul 2022 13:54:56 GMT (envelope-from git) Date: Mon, 25 Jul 2022 13:54:56 GMT Message-Id: <202207251354.26PDsuUB019847@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 9cdb0ee85da3 - stable/13 - callout: Simplify the inner loop in callout_process() a bit 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9cdb0ee85da33a4f0f4d31897f2b3601c1ca5c0b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658757296; 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=hiLag6aJnVyWgdgFPq79Rhbos3I60Y/kq53WdmQ/SZM=; b=jLHiWWy7g3pLTMgesdCDV36rR1O66Ihn0bMObJ579C0SHxhCFSWuTFY6YS9pzcDcsugQnB Tcydcfm2JnMc9SlnJ6W3XrgOwaYuNqtyiDL/fchXsHdK1q24wuK0DPchVudufOAoykjZXs iejyp9V7/N5K/dUMynzTWr7wedCPKavKWBcsARRzAQvjC/rZGxkLZTpDzDp9xN2SglKLaT UdiFBsko2ADgVaxIQiKIjBiXMp+ejBMz2QXNPKG52x4vh6qPE66uB1K5zPcbqjdwDgbYN3 RJhDFtnQztNmLt8+iFZVdR07L150lf7W/SBYUjKwdcJLPT97ZLLSeFzS4pVb7Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658757296; a=rsa-sha256; cv=none; b=XdfJRlYKMrwx3c+oPuJAz1HYXDE25GY2yyrwf7cfDZ7KqcVJXMcOnCX9+aRX4xcS0yLzCc w7VLmC7Q/oQeiqqEnnMylHG6TkdoKk56sVPftsbg7pNUpApBj8Jxc5i6DTjBMswCFNXxaN KG1Qgje68ITiwbYYGf7sq7623aHs+rwm7/vztSy7XKY0MXUxx9157tmTyMyOTKWRZlmS5A b7sUqKbAam+KuFy3Pvv9T/s95bjSMGpDRut4sgc28R2FTHd1+rypbzPOYEVxXIb4q/Qe+D 7wOy/0y96DBAYp5N1ffW+J4AJ8iCp95TNPSBb/eqQBpsGR0C56Y8gvII/JfF4A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9cdb0ee85da33a4f0f4d31897f2b3601c1ca5c0b commit 9cdb0ee85da33a4f0f4d31897f2b3601c1ca5c0b Author: Mark Johnston AuthorDate: 2022-07-01 00:16:33 +0000 Commit: Mark Johnston CommitDate: 2022-07-25 13:45:37 +0000 callout: Simplify the inner loop in callout_process() a bit - Use LIST_FOREACH_SAFE. - Simplify control flow. No functional change intended. Sponsored by: The FreeBSD Foundation (cherry picked from commit 46eab86035a1d5d2b8bfd5aae3581e2604d3ae68) --- sys/kern/kern_timeout.c | 65 +++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 016365a9bea0..c401b69b91d8 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -415,7 +415,7 @@ callout_get_bucket(sbintime_t sbt) void callout_process(sbintime_t now) { - struct callout *tmp, *tmpn; + struct callout *c, *next; struct callout_cpu *cc; struct callout_list *sc; sbintime_t first, last, lookahead, max, tmp_max; @@ -459,58 +459,55 @@ callout_process(sbintime_t now) /* Iterate callwheel from firstb to nowb and then up to lastb. */ do { sc = &cc->cc_callwheel[firstb & callwheelmask]; - tmp = LIST_FIRST(sc); - while (tmp != NULL) { + LIST_FOREACH_SAFE(c, sc, c_links.le, next) { /* Run the callout if present time within allowed. */ - if (tmp->c_time <= now) { + if (c->c_time <= now) { /* * Consumer told us the callout may be run * directly from hardware interrupt context. */ - if (tmp->c_iflags & CALLOUT_DIRECT) { + if (c->c_iflags & CALLOUT_DIRECT) { #ifdef CALLOUT_PROFILING ++depth_dir; #endif - cc_exec_next(cc) = - LIST_NEXT(tmp, c_links.le); + cc_exec_next(cc) = next; cc->cc_bucket = firstb & callwheelmask; - LIST_REMOVE(tmp, c_links.le); - softclock_call_cc(tmp, cc, + LIST_REMOVE(c, c_links.le); + softclock_call_cc(c, cc, #ifdef CALLOUT_PROFILING &mpcalls_dir, &lockcalls_dir, NULL, #endif 1); - tmp = cc_exec_next(cc); + next = cc_exec_next(cc); cc_exec_next(cc) = NULL; } else { - tmpn = LIST_NEXT(tmp, c_links.le); - LIST_REMOVE(tmp, c_links.le); + LIST_REMOVE(c, c_links.le); TAILQ_INSERT_TAIL(&cc->cc_expireq, - tmp, c_links.tqe); - tmp->c_iflags |= CALLOUT_PROCESSED; - tmp = tmpn; + c, c_links.tqe); + c->c_iflags |= CALLOUT_PROCESSED; } - continue; - } - /* Skip events from distant future. */ - if (tmp->c_time >= max) - goto next; - /* - * Event minimal time is bigger than present maximal - * time, so it cannot be aggregated. - */ - if (tmp->c_time > last) { + } else if (c->c_time >= max) { + /* + * Skip events in the distant future. + */ + ; + } else if (c->c_time > last) { + /* + * Event minimal time is bigger than present + * maximal time, so it cannot be aggregated. + */ lastb = nowb; - goto next; + } else { + /* + * Update first and last time, respecting this + * event. + */ + if (c->c_time < first) + first = c->c_time; + tmp_max = c->c_time + c->c_precision; + if (tmp_max < last) + last = tmp_max; } - /* Update first and last time, respecting this event. */ - if (tmp->c_time < first) - first = tmp->c_time; - tmp_max = tmp->c_time + tmp->c_precision; - if (tmp_max < last) - last = tmp_max; -next: - tmp = LIST_NEXT(tmp, c_links.le); } /* Proceed with the next bucket. */ firstb++;