From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
To: dccp@vger.kernel.org
Subject: Re: [PATCH 5/6]: Add history query/lookup function
Date: Sun, 17 Jun 2007 10:22:49 +0000 [thread overview]
Message-ID: <200706171122.49682@strip-the-willow> (raw)
In-Reply-To: <200706111342.02233@strip-the-willow>
| I notice there is other functionality here also...
|
| > +/**
| > + * tfrc_tx_hist_when - Retrieve send time of past packet
| > + * If successful, it garbage-collects older (irrelevant) entries and returns 1.
| > + */
| > +int tfrc_tx_hist_when(ktime_t *stamp, struct tfrc_tx_hist_head *head, u64 ackno)
| > +{
| > +
| > + if (tail)
| > + __tfrc_tx_hist_remove_tail(tail, head->cache);
| > +
|
| Can you explain the rationale behind this?
|
You have cut out half of the code, I therefore need to copy again below:
+int tfrc_tx_hist_when(ktime_t *stamp, struct tfrc_tx_hist_head *head, u64 ackno)
+{
+ struct tfrc_tx_hist *cur, *tail = NULL;
+
+ write_lock_bh(&tfrc_tx_hist_lock);
+ for (cur = head->first; cur != NULL; cur = cur->next)
+ if (cur->seqno = ackno) {
+ *stamp = cur->stamp;
+ tail = cur->next;
+ cur->next = NULL;
+ break;
+ }
+ write_unlock_bh(&tfrc_tx_hist_lock);
+
+ if (tail)
+ __tfrc_tx_hist_remove_tail(tail, head->cache);
+
+ return (cur != NULL);
+}
The patch first performs a lookup. If the lookup is successful, tail != NULL and
all entries older than `cur' (LIFO order) are cut off; at the same time tail is set
to the `tail' starting at the now old/obsolete entries.
Removing the tail is not done when under lock, since this may take time (you never
know how long the list is). So this uses a common trick of first `orphaning' the
old tail, and then doing the cleanup outside the lock-protected region, when there
is more time to do so.
Maybe you have noted that the subsequent patch (6/6) has the following hunk:
@@ -492,9 +488,6 @@ static void ccid3_hc_tx_packet_recv(stru
/* unschedule no feedback timer */
sk_stop_timer(sk, &hctx->ccid3hctx_no_feedback_timer);
- /* remove all packets older than the one acked from history */
- dccp_tx_hist_purge_older(ccid3_tx_hist,
- &hctx->ccid3hctx_hist, packet);
/*
* As we have calculated new ipi, delta, t_nom it is possible
* that we now can send a packet, so wake up dccp_wait_for_ccid
=> The above effectively replaces this in one go. This is better since otherwise
the same lock would need to be acquired twice - once for reading, then for
writing (to perform the purge). This would introduce a race condition.
=> You can find this also in the documentation of patch 5/6:
+ * tfrc_tx_hist_when - Retrieve send time of past packet
+
+ * If successful, it garbage-collects older (irrelevant) entries and returns 1.
+ */
next prev parent reply other threads:[~2007-06-17 10:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-11 12:42 [PATCH 5/6]: Add history query/lookup function Gerrit Renker
2007-06-16 23:07 ` Ian McDonald
2007-06-16 23:11 ` Ian McDonald
2007-06-17 10:22 ` Gerrit Renker [this message]
2007-06-17 10:26 ` Gerrit Renker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200706171122.49682@strip-the-willow \
--to=gerrit@erg.abdn.ac.uk \
--cc=dccp@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox