From nobody Sun Jul 17 17:58:40 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 4LmCWh4k82z4Wv6w; Sun, 17 Jul 2022 17:58: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 4LmCWh4Gxxz43ST; Sun, 17 Jul 2022 17:58:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658080720; 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=vwoZpwThJnM/J91xdBdCb5hgUwHrWGt/bySNBZK65DQ=; b=R0FlyNtZoi4G90nAqHS4rNeHQVUT2lBzxpWj4tJQpodPCTxFByZa3fD4PxEGBEz3qfRH/w u0KBavUXG2R1uA1Eu3YpEcYA+sloNdUW67GOVU/n1Ej0mIl5Chb6aW+4DAZaRPFDfootk0 YmCDHEhyLgS0woTb9EWDGu7aNLry7IdmqQuMux0v1N1mfKmUloDEQEDNVmQDKdrMEuDc8p dUOITlds5MGfeJV3U88xeAnfsV3KZhxZzEmRUIEVuTMF4ER+RJOJTuriUijNEkShx80twi wRDSavmluS9iFxEhqSkMd9GIEgAUiyxwf/NFA7xoq0bFrTUKUB3mfk/2UkuaMA== 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 4LmCWh3LqPz184M; Sun, 17 Jul 2022 17:58:40 +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 26HHweKU043543; Sun, 17 Jul 2022 17:58:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26HHwePd043542; Sun, 17 Jul 2022 17:58:40 GMT (envelope-from git) Date: Sun, 17 Jul 2022 17:58:40 GMT Message-Id: <202207171758.26HHwePd043542@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 46eab86035a1 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 46eab86035a1d5d2b8bfd5aae3581e2604d3ae68 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658080720; 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=vwoZpwThJnM/J91xdBdCb5hgUwHrWGt/bySNBZK65DQ=; b=rzRz0fm5ZTUclBVBCbQWySH5q3KNKViWW+TBaPsOIIozxR6uyQOg7tY9Csn+xZMIJUtpYH i+/h8BTrtL1oaGDQnvbwPBqY/7l90DPckfguX+dd84Mu/V+l9ud2GDjbQhMQL8xUup5I9S VAsUcZ9Ml+WG76uTDvOh29221uL5kSp7sv6pa5JqkFtg+NpC3/E41Gt8C1nCDZSL69Mtzj wt/afAe4/xO7mM86TqVbjae382GwMpR49qKBYKZ4iTddxiY7vhjZtzuHReB+keJ1KYKbs2 DvkpG2Vrfk+tmS96i+UgAi9+FwlC0/49feFJReUoDgGZ3OGZxfM+XAHgOO+buw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658080720; a=rsa-sha256; cv=none; b=hCeweRJCktMnUU4wI+wNjLDYIpBzxIX5/FoIZkwwu6RouclINGxmX34VgD7Wn1ZI3Y6H7g VMiNA5AYRIajV5yUIw8B3M61aOND9goBLrRhdAgrQND40j9SCbjQUXAfKcECRqDruEj3G1 pkyLE7sQuKDA1m/8eQwW2B2QLen52MQuTGb0RtTHuPcot5aNyo7o18Oh1tizORv//KlPev tzKrLvRYXjgW0sCRAO+UtQYi7XSm6kiAff3sPRpR3sKChh3++qJ8ed361o837WfIWNOw5/ YRArWZl7Fqq1EVEOHt6qlKmpuazBcHb2vWMlBqSk+UKtaKbK65+RhUi+rMQcOQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=46eab86035a1d5d2b8bfd5aae3581e2604d3ae68 commit 46eab86035a1d5d2b8bfd5aae3581e2604d3ae68 Author: Mark Johnston AuthorDate: 2022-07-01 00:16:33 +0000 Commit: Mark Johnston CommitDate: 2022-07-17 17:58:19 +0000 callout: Simplify the inner loop in callout_process() a bit - Use LIST_FOREACH_SAFE. - Simplify control flow. No functional change intended. MFC after: 1 week Sponsored by: The FreeBSD Foundation --- 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 2bd469f94080..5c6c49ec93bd 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -434,7 +434,7 @@ callout_process(sbintime_t now) struct thread *td; sbintime_t now; } entropy; - struct callout *tmp, *tmpn; + struct callout *c, *next; struct callout_cpu *cc; struct callout_list *sc; struct thread *td; @@ -479,58 +479,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++;