diff mbox series

use might_sleep check if kmap_high is called from atomic context

Message ID 1724118791-51554-1-git-send-email-zhang.chuna@h3c.com (mailing list archive)
State New
Headers show
Series use might_sleep check if kmap_high is called from atomic context | expand

Commit Message

zhangchun Aug. 20, 2024, 1:53 a.m. UTC
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(+)

Comments

Matthew Wilcox Aug. 20, 2024, 3:24 a.m. UTC | #1
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().
zhangchun Aug. 20, 2024, 6:33 a.m. UTC | #2
>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>
diff mbox series

Patch

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.
 	 */