diff mbox series

[RFC,v7,08/23] dept: Apply sdt_might_sleep_strong() to PG_{locked,writeback} wait

Message ID 1673235231-30302-9-git-send-email-byungchul.park@lge.com (mailing list archive)
State New, archived
Headers show
Series DEPT(Dependency Tracker) | expand

Commit Message

Byungchul Park Jan. 9, 2023, 3:33 a.m. UTC
Makes Dept able to track dependencies by PG_{locked,writeback} waits.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
 mm/filemap.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Sergey Shtylyov Jan. 9, 2023, 9:10 a.m. UTC | #1
On 1/9/23 6:33 AM, Byungchul Park wrote:

> Makes Dept able to track dependencies by PG_{locked,writeback} waits.
> 
> Signed-off-by: Byungchul Park <byungchul.park@lge.com>
> ---
>  mm/filemap.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/mm/filemap.c b/mm/filemap.c
> index c4d4ace..b013a5b 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
[...]
> @@ -1226,6 +1230,11 @@ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,
>  	unsigned long pflags;
>  	bool in_thrashing;
>  
> +	if (bit_nr == PG_locked)
> +		sdt_might_sleep_strong(&PG_locked_map);
> +	else if (bit_nr == PG_writeback)
> +		sdt_might_sleep_strong(&PG_writeback_map);

   Hm, this is asking to be a *switch* statement instead...

[...]

MBR, Sergey
diff mbox series

Patch

diff --git a/mm/filemap.c b/mm/filemap.c
index c4d4ace..b013a5b 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -42,6 +42,7 @@ 
 #include <linux/ramfs.h>
 #include <linux/page_idle.h>
 #include <linux/migrate.h>
+#include <linux/dept_sdt.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 #include "internal.h"
@@ -1215,6 +1216,9 @@  static inline bool folio_trylock_flag(struct folio *folio, int bit_nr,
 /* How many times do we accept lock stealing from under a waiter? */
 int sysctl_page_lock_unfairness = 5;
 
+static struct dept_map __maybe_unused PG_locked_map = DEPT_MAP_INITIALIZER(PG_locked_map, NULL);
+static struct dept_map __maybe_unused PG_writeback_map = DEPT_MAP_INITIALIZER(PG_writeback_map, NULL);
+
 static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,
 		int state, enum behavior behavior)
 {
@@ -1226,6 +1230,11 @@  static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,
 	unsigned long pflags;
 	bool in_thrashing;
 
+	if (bit_nr == PG_locked)
+		sdt_might_sleep_strong(&PG_locked_map);
+	else if (bit_nr == PG_writeback)
+		sdt_might_sleep_strong(&PG_writeback_map);
+
 	if (bit_nr == PG_locked &&
 	    !folio_test_uptodate(folio) && folio_test_workingset(folio)) {
 		delayacct_thrashing_start(&in_thrashing);
@@ -1327,6 +1336,8 @@  static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,
 	 */
 	finish_wait(q, wait);
 
+	sdt_might_sleep_finish();
+
 	if (thrashing) {
 		delayacct_thrashing_end(&in_thrashing);
 		psi_memstall_leave(&pflags);