mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Barry Song <21cnbao@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	justinjiang@vivo.com, chrisl@kernel.org, hughd@google.com,
	kaleshsingh@google.com, kasong@tencent.com,
	linux-kernel@vger.kernel.org, ryan.roberts@arm.com,
	v-songbaohua@oppo.com, ying.huang@intel.com
Subject: Re: [PATCH v2 2/2] mm: attempt to batch free swap entries for zap_pte_range()
Date: Wed, 7 Aug 2024 12:19:35 +0200	[thread overview]
Message-ID: <04a1b98e-efd1-4a77-8f42-7aa5255306b2@redhat.com> (raw)
In-Reply-To: <CAGsJ_4zFfnwc1kstNO53gdeUzzon5_tamDcC-mTUUS_PQEjF0A@mail.gmail.com>

>>
>>> +     if (!has_cache) {
>>> +             spin_lock(&si->lock);
>>
>> I'm no expert on that code, but we might drop the cluster lock the take
>> the swap_info lock and then retake the cluster lock. I assume there are
>> no races we are worrying about here, right?
> 
> I suppose so. Even the original single-entry code follows the same pattern:
> 
> static unsigned char __swap_entry_free(struct swap_info_struct *p,
>         swp_entry_t entry)
> {
>           struct swap_cluster_info *ci;
>           unsigned long offset = swp_offset(entry);
>           unsigned char usage;
> 
>           ci = lock_cluster_or_swap_info(p, offset);
>           usage = __swap_entry_free_locked(p, offset, 1);
>           unlock_cluster_or_swap_info(p, ci);
>           if (!usage)
>                    free_swap_slot(entry);
> 
>           return usage;
> }
> 
> I assume that once we mark them as SWAP_HAS_CACHE, no one else
> will touch them except ourselves.

That makes sense, thanks!

-- 
Cheers,

David / dhildenb


  reply	other threads:[~2024-08-07 10:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07  8:25 [PATCH v2 0/2] mm: batch free swaps " Barry Song
2024-08-07  8:25 ` [PATCH v2 1/2] mm: rename instances of swap_info_struct to meaningful 'si' Barry Song
2024-08-07  9:11   ` David Hildenbrand
2024-08-07  8:25 ` [PATCH v2 2/2] mm: attempt to batch free swap entries for zap_pte_range() Barry Song
2024-08-07  9:28   ` David Hildenbrand
2024-08-07  9:48     ` Barry Song
2024-08-07 10:19       ` David Hildenbrand [this message]
2024-08-07 16:16   ` Kairui Song
2024-08-07 19:14     ` Barry Song

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=04a1b98e-efd1-4a77-8f42-7aa5255306b2@redhat.com \
    --to=david@redhat.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chrisl@kernel.org \
    --cc=hughd@google.com \
    --cc=justinjiang@vivo.com \
    --cc=kaleshsingh@google.com \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=v-songbaohua@oppo.com \
    --cc=ying.huang@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

all inboxes | Powered by JetHome®