[PATCH] use might_sleep check if kmap_high is called from atomic context

zhangchun posted 1 patch 1 year, 5 months ago
mm/highmem.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] use might_sleep check if kmap_high is called from atomic context
Posted by zhangchun 1 year, 5 months ago
kmap_high is defined as EXPORT_SYMBOL, and cannot be called from atomic
context. Add might_sleep check is necessary.
Signed-off-by: zhangchun <zhang.chuna@h3c.com>
---
 mm/highmem.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mm/highmem.c b/mm/highmem.c
index 07f2c67..5cfb5a9 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -319,6 +319,11 @@ void *kmap_high(struct page *page)
 	unsigned long vaddr;
 
 	/*
+	 * Use might_sleep to check if kmap_high is called
+	 * from atomic context.
+	 */
+	might_sleep();
+	/*
 	 * For highmem pages, we can't trust "virtual" until
 	 * after we have the lock.
 	 */
-- 
1.8.3.1
Re: [PATCH] use might_sleep check if kmap_high is called from atomic context
Posted by Matthew Wilcox 1 year, 5 months ago
On Tue, Aug 20, 2024 at 09:53:11AM +0800, zhangchun wrote:
> kmap_high is defined as EXPORT_SYMBOL, and cannot be called from atomic
> context. Add might_sleep check is necessary.

No.  Nobody should be calling kmap_high() directly.  There's already a
might_sleep() in kmap().  No need to add one in kmap_high().
[PATCH] use might_sleep check if kmap_high is called from atomic context
Posted by zhangchun 1 year, 5 months ago
>On Tue, Aug 20, 2024 at 09:53:11AM +0800, zhangchun wrote:
>> kmap_high is defined as EXPORT_SYMBOL, and cannot be called from 
>> atomic context. Add might_sleep check is necessary.

>No.  Nobody should be calling kmap_high() directly.  There's already a
>might_sleep() in kmap().  No need to add one in kmap_high().

To avoid anyone calls kmap_high directly, add function description "Don't
use kmap_high directly, if necessary, please use kmap"
Signed-off-by: zhangchun <zhang.chuna@h3c.com>
-- 
1.8.3.1