All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: drbd-dev@lists.linbit.com, linux-kernel@vger.kernel.org,
	"Lars Ellenberg" <lars.ellenberg@linbit.com>,
	"Philipp Reisner" <philipp.reisner@linbit.com>,
	linux-block@vger.kernel.org,
	"Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>
Subject: [PATCH 1/4] lru_cache: use atomic operations when accessing lc->flags, always
Date: Tue, 22 Nov 2022 14:42:58 +0100	[thread overview]
Message-ID: <20221122134301.69258-2-christoph.boehmwalder@linbit.com> (raw)
In-Reply-To: <20221122134301.69258-1-christoph.boehmwalder@linbit.com>

From: Lars Ellenberg <lars.ellenberg@linbit.com>

Or, depending on the way locking is implemented at the call sites,
some updates could be lost (has not been observed).

Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
---
 lib/lru_cache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/lru_cache.c b/lib/lru_cache.c
index dc35464216d3..fec899386238 100644
--- a/lib/lru_cache.c
+++ b/lib/lru_cache.c
@@ -364,7 +364,7 @@ static struct lc_element *__lc_get(struct lru_cache *lc, unsigned int enr, unsig
 	struct lc_element *e;
 
 	PARANOIA_ENTRY();
-	if (lc->flags & LC_STARVING) {
+	if (test_bit(__LC_STARVING, &lc->flags)) {
 		++lc->starving;
 		RETURN(NULL);
 	}
@@ -417,7 +417,7 @@ static struct lc_element *__lc_get(struct lru_cache *lc, unsigned int enr, unsig
 	 * the LRU element, we have to wait ...
 	 */
 	if (!lc_unused_element_available(lc)) {
-		__set_bit(__LC_STARVING, &lc->flags);
+		set_bit(__LC_STARVING, &lc->flags);
 		RETURN(NULL);
 	}
 
-- 
2.38.1


  reply	other threads:[~2022-11-22 13:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-22 13:42 [PATCH 0/4] lru_cache improvements, DRBD license identifiers Christoph Böhmwalder
2022-11-22 13:42 ` Christoph Böhmwalder [this message]
2022-11-22 13:42 ` [PATCH 2/4] lru_cache: remove compiled out code Christoph Böhmwalder
2022-11-22 13:43 ` [PATCH 3/4] lru_cache: remove unused lc_private, lc_set, lc_index_of Christoph Böhmwalder
2022-11-22 13:43 ` [PATCH 4/4] drbd: use consistent license Christoph Böhmwalder

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=20221122134301.69258-2-christoph.boehmwalder@linbit.com \
    --to=christoph.boehmwalder@linbit.com \
    --cc=axboe@kernel.dk \
    --cc=drbd-dev@lists.linbit.com \
    --cc=lars.ellenberg@linbit.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=philipp.reisner@linbit.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.