All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Documentation of locking needs when working with lists?
Date: Sat, 10 May 2025 15:20:47 +0200	[thread overview]
Message-ID: <2025051012-karma-setting-af04@gregkh> (raw)
In-Reply-To: <4f405d9b-460c-49f7-91b2-d147d9818369@gmail.com>

On Sat, May 10, 2025 at 10:46:32AM +0200, Heiner Kallweit wrote:
> Even though lists are used everywhere, I was surprised not being able to find
> documentation about which operations need locking, and which ones are safe
> lock-less.
> 
> My case:
> I have a list where the only operation is adding entries.
> It's clear that adding entries has to be serialized.
> Question is whether a list_for_each_entry is safe lock-less.
> 
> Looking at the code I *think* it's safe, under the precondition that
> reading/writing pointers is atomic.
> 
> Any hint or documentation link would be appreciated. Thanks!

You MUST have locking for your list if you have multiple processes
accessing it at the same time.

good luck!

greg k-h

  reply	other threads:[~2025-05-10 13:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-10  8:46 Documentation of locking needs when working with lists? Heiner Kallweit
2025-05-10 13:20 ` Greg Kroah-Hartman [this message]
2025-05-10 20:46   ` Heiner Kallweit
2025-05-13 21:42 ` David Laight

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=2025051012-karma-setting-af04@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=hkallweit1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@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 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.