All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] md: avoid counter operation conflicts
@ 2024-03-26 10:29 tada keisuke
  2024-03-26 14:01 ` Yu Kuai
  2024-04-10 21:13 ` Song Liu
  0 siblings, 2 replies; 4+ messages in thread
From: tada keisuke @ 2024-03-26 10:29 UTC (permalink / raw)
  To: song, yukuai3; +Cc: linux-raid, linux-kernel

Currently, active_aligned_reads and nr_pending used as counters are atomic types.
Therefore, when inc/dec in a multi-core results in conflicts.

To solve this problem, use "percpu_ref" counters that can avoid conflicts and maintain consistency.

Switch modes of percpu_ref to achieve both consistency and conflict avoidance.
During normal operations such as inc/dec, it operates as percpu mode.
When consistency is required, it operates as atomic mode.
The operations that require consistency are as follows:
・Zero check for the counter
・All operations in RAID 1/10

Patches 1, 3, 6 change active_aligned_reads, and patches 2, 4, 5, 7 to 11 change nr_pending.
nr_pending temporarily switch from percpu mode to atomic mode in patch 7.
This is to reduce the amount of changes from patches 8 to 10.
Finally, nr_pending switch from atomic mode to percpu mode in patch 11.

Keisuke TADA (11):
  add infra for active_aligned_reads changes
  add infra for nr_pending changes
  workaround for inconsistency of config state in takeover
  minimize execution of zero check for nr_pending
  match the type of variables to percpu_ref
  avoid conflicts in active_aligned_reads operations
  change the type of nr_pending from atomic_t to percpu_ref
  add atomic mode switching in RAID 1/10
  add atomic mode switching when removing disk
  add atomic mode switching when I/O completion
  avoid conflicts in nr_pending operations

 drivers/md/md-bitmap.c   |  2 +-
 drivers/md/md.c          | 40 +++++++++++++++---
 drivers/md/md.h          | 62 ++++++++++++++++++++++++----
 drivers/md/raid1.c       | 37 +++++++++++------
 drivers/md/raid10.c      | 60 ++++++++++++++++-----------
 drivers/md/raid5-cache.c |  4 +-
 drivers/md/raid5.c       | 89 +++++++++++++++++++++++++++-------------
 drivers/md/raid5.h       | 17 +++++++-
 8 files changed, 230 insertions(+), 81 deletions(-)


base-commit: fcf3f7e2fc8a53a6140beee46ec782a4c88e4744
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 00/11] md: avoid counter operation conflicts
  2024-03-26 10:29 [PATCH 00/11] md: avoid counter operation conflicts tada keisuke
@ 2024-03-26 14:01 ` Yu Kuai
  2024-03-27  1:27   ` tada keisuke
  2024-04-10 21:13 ` Song Liu
  1 sibling, 1 reply; 4+ messages in thread
From: Yu Kuai @ 2024-03-26 14:01 UTC (permalink / raw)
  To: tada keisuke, song; +Cc: linux-raid, linux-kernel, yukuai (C)

Hi,

在 2024/03/26 18:29, tada keisuke 写道:
> Currently, active_aligned_reads and nr_pending used as counters are atomic types.
> Therefore, when inc/dec in a multi-core results in conflicts.

I don't uderstand what's the problem here, what's wrong with atomic
types in a multi-core system?

Thanks,
Kuai


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 00/11] md: avoid counter operation conflicts
  2024-03-26 14:01 ` Yu Kuai
@ 2024-03-27  1:27   ` tada keisuke
  0 siblings, 0 replies; 4+ messages in thread
From: tada keisuke @ 2024-03-27  1:27 UTC (permalink / raw)
  To: Yu Kuai, song; +Cc: linux-raid, linux-kernel, yukuai (C)

>> Currently, active_aligned_reads and nr_pending used as counters are atomic types.
>> Therefore, when inc/dec in a multi-core results in conflicts.
>
> I don't uderstand what's the problem here, what's wrong with atomic
> types in a multi-core system?

Hi Kuai

This patch is not a fix for the problem, but an improvement.
This patch makes the counter inc/dec faster.

For the same reason, active_io was changed from atomic_t to percpu_ref.
https://marc.info/?l=linux-raid&m=167514225920879

Thanks,
Keisuke


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 00/11] md: avoid counter operation conflicts
  2024-03-26 10:29 [PATCH 00/11] md: avoid counter operation conflicts tada keisuke
  2024-03-26 14:01 ` Yu Kuai
@ 2024-04-10 21:13 ` Song Liu
  1 sibling, 0 replies; 4+ messages in thread
From: Song Liu @ 2024-04-10 21:13 UTC (permalink / raw)
  To: tada keisuke; +Cc: yukuai3, linux-raid, linux-kernel

Thanks for the patchset!

On Tue, Mar 26, 2024 at 3:29 AM tada keisuke <keisuke1.tada@kioxia.com> wrote:
>
> Currently, active_aligned_reads and nr_pending used as counters are atomic types.
> Therefore, when inc/dec in a multi-core results in conflicts.
>
> To solve this problem, use "percpu_ref" counters that can avoid conflicts and maintain consistency.
>
> Switch modes of percpu_ref to achieve both consistency and conflict avoidance.
> During normal operations such as inc/dec, it operates as percpu mode.
> When consistency is required, it operates as atomic mode.
> The operations that require consistency are as follows:
> ・Zero check for the counter
> ・All operations in RAID 1/10

IIUC, the patchset is to resolve race conditions and thus improve performance.
If this is the case, could you please include some performance numbers in the
next version?

Thanks,
Song

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-10 21:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-26 10:29 [PATCH 00/11] md: avoid counter operation conflicts tada keisuke
2024-03-26 14:01 ` Yu Kuai
2024-03-27  1:27   ` tada keisuke
2024-04-10 21:13 ` Song Liu

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.