linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Zhi Jin <zhi.jin@intel.com>
Cc: linux-kernel@vger.kernel.org, Zhi Jin <zhi.jin@intel.com>
Subject: Re: [PATCH] stm class: increase pos if no free channels found
Date: Mon, 15 Oct 2018 10:42:37 +0300	[thread overview]
Message-ID: <87h8hn64gi.fsf@ashishki-desk.ger.corp.intel.com> (raw)
In-Reply-To: <1536218530-18601-1-git-send-email-zhi.jin@intel.com>

Zhi Jin <zhi.jin@intel.com> writes:

> Considering this case in find_free_channels():
>
> bitmap:
>        +------------------+-+-+-+-+-+-+-+-+-+-+
>        |     ......       |0|0|0|0|0|0|0|1|0|0|
>        +------------------+-+-+-+-+-+-+-+-+-+-+
>
> 1. Channel #2 has been occupied, so bit #2 is 1, and the others
>    are all 0.
> 2. Another thread tries to find 4 free channels from #0.
> 3. In the 1st loop, pos starts from 0, and then it checks if the
>    following 4 bits are all 0, but fails, as bit#2 is 1.
> 4. In the 2st loop, pos is not updated, and still starts from 0,
>    so nothing changes against loop #1.
> 5. Dead loop ...
>
> This patch is to update the pos in step #3 to avoid the issue.

The description is slightly confusing, but the patch looks correct and
the original code is clearly wrong. Thank you for finding this!

Basically, if you request 1 channel 3 times, release the first two and
then request 4 channels, you'll be stuck, right?

Thanks,
--
Alex

  parent reply	other threads:[~2018-10-15  7:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06  7:22 [PATCH] stm class: increase pos if no free channels found Zhi Jin
2018-10-12  5:36 ` Jin, Zhi
2018-10-15  7:42 ` Alexander Shishkin [this message]
2018-10-15  8:16   ` Jin, Zhi

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=87h8hn64gi.fsf@ashishki-desk.ger.corp.intel.com \
    --to=alexander.shishkin@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zhi.jin@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).