* [PATCH] mm: workingset: Simplify lockdep check in update_node
@ 2025-04-21 17:16 Pedro Falcato
2025-04-21 17:39 ` Pedro Falcato
2025-04-24 19:17 ` Johannes Weiner
0 siblings, 2 replies; 4+ messages in thread
From: Pedro Falcato @ 2025-04-21 17:16 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, linux-kernel, Pedro Falcato
container_of(node->array, ..., i_pages) just to access i_pages again
is an incredibly roundabout way of accessing node->array itself.
Simplify it.
Signed-off-by: Pedro Falcato <pfalcato@suse.de>
---
mm/workingset.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/mm/workingset.c b/mm/workingset.c
index 4841ae8af41113797378846f08336cd7c5757bd5..6e7f4cb1b9a7807e9288955f180a5b6cffab1a40 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -612,7 +612,6 @@ struct list_lru shadow_nodes;
void workingset_update_node(struct xa_node *node)
{
- struct address_space *mapping;
struct page *page = virt_to_page(node);
/*
@@ -623,8 +622,7 @@ void workingset_update_node(struct xa_node *node)
* already where they should be. The list_empty() test is safe
* as node->private_list is protected by the i_pages lock.
*/
- mapping = container_of(node->array, struct address_space, i_pages);
- lockdep_assert_held(&mapping->i_pages.xa_lock);
+ lockdep_assert_held(&node->array->xa_lock);
if (node->count && node->count == node->nr_values) {
if (list_empty(&node->private_list)) {
---
base-commit: 856ddd6c69a1a1935f32de8411550d997bcbe6f5
change-id: 20250421-workingset-simplify-eef38019a78c
Best regards,
--
Pedro Falcato <pfalcato@suse.de>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] mm: workingset: Simplify lockdep check in update_node
2025-04-21 17:16 [PATCH] mm: workingset: Simplify lockdep check in update_node Pedro Falcato
@ 2025-04-21 17:39 ` Pedro Falcato
2025-04-23 2:07 ` Matthew Wilcox
2025-04-24 19:17 ` Johannes Weiner
1 sibling, 1 reply; 4+ messages in thread
From: Pedro Falcato @ 2025-04-21 17:39 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, linux-kernel, Sebastian Andrzej Siewior
On Mon, Apr 21, 2025 at 06:16:28PM +0100, Pedro Falcato wrote:
> container_of(node->array, ..., i_pages) just to access i_pages again
> is an incredibly roundabout way of accessing node->array itself.
> Simplify it.
>
> Signed-off-by: Pedro Falcato <pfalcato@suse.de>
> ---
> mm/workingset.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/mm/workingset.c b/mm/workingset.c
> index 4841ae8af41113797378846f08336cd7c5757bd5..6e7f4cb1b9a7807e9288955f180a5b6cffab1a40 100644
> --- a/mm/workingset.c
> +++ b/mm/workingset.c
> @@ -612,7 +612,6 @@ struct list_lru shadow_nodes;
>
> void workingset_update_node(struct xa_node *node)
> {
> - struct address_space *mapping;
> struct page *page = virt_to_page(node);
>
> /*
> @@ -623,8 +622,7 @@ void workingset_update_node(struct xa_node *node)
> * already where they should be. The list_empty() test is safe
> * as node->private_list is protected by the i_pages lock.
> */
> - mapping = container_of(node->array, struct address_space, i_pages);
> - lockdep_assert_held(&mapping->i_pages.xa_lock);
> + lockdep_assert_held(&node->array->xa_lock);
>
> if (node->count && node->count == node->nr_values) {
> if (list_empty(&node->private_list)) {
>
Actually, not sure if this is wanted given the original code is a little more
explicit on what the lock is. +CC the original author
If people think this is worse, just drop the patch, I don't really care - was just
checking out the function for other purposes and found this bit a little confusing.
--
Pedro
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] mm: workingset: Simplify lockdep check in update_node
2025-04-21 17:39 ` Pedro Falcato
@ 2025-04-23 2:07 ` Matthew Wilcox
0 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2025-04-23 2:07 UTC (permalink / raw)
To: Pedro Falcato
Cc: Andrew Morton, linux-mm, linux-kernel, Sebastian Andrzej Siewior
On Mon, Apr 21, 2025 at 06:39:53PM +0100, Pedro Falcato wrote:
> Actually, not sure if this is wanted given the original code is a little more
> explicit on what the lock is. +CC the original author
>
> If people think this is worse, just drop the patch, I don't really care - was just
> checking out the function for other purposes and found this bit a little confusing.
I think it's clearer.
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: workingset: Simplify lockdep check in update_node
2025-04-21 17:16 [PATCH] mm: workingset: Simplify lockdep check in update_node Pedro Falcato
2025-04-21 17:39 ` Pedro Falcato
@ 2025-04-24 19:17 ` Johannes Weiner
1 sibling, 0 replies; 4+ messages in thread
From: Johannes Weiner @ 2025-04-24 19:17 UTC (permalink / raw)
To: Pedro Falcato; +Cc: Andrew Morton, linux-mm, linux-kernel
On Mon, Apr 21, 2025 at 06:16:28PM +0100, Pedro Falcato wrote:
> container_of(node->array, ..., i_pages) just to access i_pages again
> is an incredibly roundabout way of accessing node->array itself.
> Simplify it.
Agreed. The other side is shadow_lru_isolate() which goes also goes
through mapping->i_pages. That's probably how it came to be. But your
patch doesn't make that relationship any harder to understand.
> Signed-off-by: Pedro Falcato <pfalcato@suse.de>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-24 19:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-21 17:16 [PATCH] mm: workingset: Simplify lockdep check in update_node Pedro Falcato
2025-04-21 17:39 ` Pedro Falcato
2025-04-23 2:07 ` Matthew Wilcox
2025-04-24 19:17 ` Johannes Weiner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox