Message ID | 20190228062405.32107-5-lsahlber@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Simplify credits handling for compound requests | expand |
ср, 27 февр. 2019 г. в 22:26, Ronnie Sahlberg <lsahlber@redhat.com>: > > Reserve the last MAX_COMPOUND credits for any request asking for >1 credit. > This is to prevent future compound requests from becoming starved while waiting > for potentially many requests is there is a large number of concurrent > singe-credit requests. > > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> > --- > fs/cifs/transport.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c > index baf15194aa3d..4ff832fce2e9 100644 > --- a/fs/cifs/transport.c > +++ b/fs/cifs/transport.c > @@ -520,6 +520,29 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, > } > > /* > + * For normal commands, reserve the last MAX_COMPOUND > + * credits to compound requests. > + * Otherwise these compounds could be permanently > + * starved for credits by single-credit requests. > + * > + * To prevent spinning CPU, block this thread until > + * there are >MAX_COMPOUND credits available. > + */ > + if (!optype && num_credits == 1 && What if server decides to grants us credits gradually? E.g. granted only 2 during negotiate protocol and session setup. The tree connect will wait forever here. > + *credits <= MAX_COMPOUND) { > + spin_unlock(&server->req_lock); > + cifs_num_waiters_inc(server); > + rc = wait_event_killable(server->request_q, > + has_credits(server, credits, > + MAX_COMPOUND + 1)); > + cifs_num_waiters_dec(server); > + if (rc) > + return rc; > + spin_lock(&server->req_lock); > + continue; > + } > + > + /* > * Can not count locking commands against total > * as they are allowed to block on server. > */ > -- > 2.13.6 > -- Best regards, Pavel Shilovsky
On Sat, Mar 2, 2019 at 11:41 AM Pavel Shilovsky <piastryyy@gmail.com> wrote: > > ср, 27 февр. 2019 г. в 22:26, Ronnie Sahlberg <lsahlber@redhat.com>: > > > > Reserve the last MAX_COMPOUND credits for any request asking for >1 credit. > > This is to prevent future compound requests from becoming starved while waiting > > for potentially many requests is there is a large number of concurrent > > singe-credit requests. > > > > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> > > --- > > fs/cifs/transport.c | 23 +++++++++++++++++++++++ > > 1 file changed, 23 insertions(+) > > > > diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c > > index baf15194aa3d..4ff832fce2e9 100644 > > --- a/fs/cifs/transport.c > > +++ b/fs/cifs/transport.c > > @@ -520,6 +520,29 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, > > } > > > > /* > > + * For normal commands, reserve the last MAX_COMPOUND > > + * credits to compound requests. > > + * Otherwise these compounds could be permanently > > + * starved for credits by single-credit requests. > > + * > > + * To prevent spinning CPU, block this thread until > > + * there are >MAX_COMPOUND credits available. > > + */ > > + if (!optype && num_credits == 1 && > > What if server decides to grants us credits gradually? E.g. granted > only 2 during negotiate protocol and session setup. The tree connect > will wait forever here. Thanks. You are right. That should be avoidable by checking for and only doing this if we have <arbitrary large> number of credits already in flight. I will send an updated series. > > > + *credits <= MAX_COMPOUND) { > > + spin_unlock(&server->req_lock); > > + cifs_num_waiters_inc(server); > > + rc = wait_event_killable(server->request_q, > > + has_credits(server, credits, > > + MAX_COMPOUND + 1)); > > + cifs_num_waiters_dec(server); > > + if (rc) > > + return rc; > > + spin_lock(&server->req_lock); > > + continue; > > + } > > + > > + /* > > * Can not count locking commands against total > > * as they are allowed to block on server. > > */ > > -- > > 2.13.6 > > > > > -- > Best regards, > Pavel Shilovsky
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index baf15194aa3d..4ff832fce2e9 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -520,6 +520,29 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, } /* + * For normal commands, reserve the last MAX_COMPOUND + * credits to compound requests. + * Otherwise these compounds could be permanently + * starved for credits by single-credit requests. + * + * To prevent spinning CPU, block this thread until + * there are >MAX_COMPOUND credits available. + */ + if (!optype && num_credits == 1 && + *credits <= MAX_COMPOUND) { + spin_unlock(&server->req_lock); + cifs_num_waiters_inc(server); + rc = wait_event_killable(server->request_q, + has_credits(server, credits, + MAX_COMPOUND + 1)); + cifs_num_waiters_dec(server); + if (rc) + return rc; + spin_lock(&server->req_lock); + continue; + } + + /* * Can not count locking commands against total * as they are allowed to block on server. */
Reserve the last MAX_COMPOUND credits for any request asking for >1 credit. This is to prevent future compound requests from becoming starved while waiting for potentially many requests is there is a large number of concurrent singe-credit requests. Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> --- fs/cifs/transport.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)