Skip to contentSkip to conversation

memalloc_noio: update the comment to make it cleaner

RFC PATCH In review [email protected] 2 participants 5 messages Sep 17, 2019 – Sep 18, 2019

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 memalloc_noio: update the comment to make it cleaner

From: Xiubo Li <[email protected]>

The GFP_NOIO means all further allocations will implicitly drop both __GFP_IO and __GFP_FS flags and so they are safe for both the IO critical section and the the critical section from the allocation recursion point of view. Not only the __GFP_IO, which a bit confusing when reading the code or using the save/restore pair.

---
 include/linux/sched/mm.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
include/linux/sched/mm.h +5 -4
index 4a7944078cc3..9bdc97e52de1 100644
@@ -211,10 +211,11 @@ static inline void fs_reclaim_release(gfp_t gfp_mask) { }
  * memalloc_noio_save - Marks implicit GFP_NOIO allocation scope.
  *
  * This functions marks the beginning of the GFP_NOIO allocation scope.
- * All further allocations will implicitly drop __GFP_IO flag and so
- * they are safe for the IO critical section from the allocation recursion
- * point of view. Use memalloc_noio_restore to end the scope with flags
- * returned by this function.
+ * All further allocations will implicitly drop __GFP_IO and __GFP_FS
+ * flags and so they are safe for both the IO critical section and the
+ * the critical section from the allocation recursion point of view. Use
+ * memalloc_noio_restore to end the scope with flags returned by this
+ * function.
  *
  * This function is safe to be used from any context.
  */
Signature · 1 line
2.21.0
#1 lore raw
Quoted 7 lines · On Wed 18-09-19 04:58:20, [email protected] wrote:

From: Xiubo Li <[email protected]>

The GFP_NOIO means all further allocations will implicitly drop both __GFP_IO and __GFP_FS flags and so they are safe for both the IO critical section and the the critical section from the allocation recursion point of view. Not only the __GFP_IO, which a bit confusing when reading the code or using the save/restore pair.

Historically GFP_NOIO has always implied GFP_NOFS as well. I can imagine that this might come as an surprise for somebody not familiar with the code though. I am wondering whether your update of the documentation would be better off at __GFP_FS, __GFP_IO resp. GFP_NOFS, GFP_NOIO level. This interface is simply a way to set a scoped NO{IO,FS} context.

Quoted 27 lines
---
 include/linux/sched/mm.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
include/linux/sched/mm.h +5 -4
index 4a7944078cc3..9bdc97e52de1 100644
@@ -211,10 +211,11 @@ static inline void fs_reclaim_release(gfp_t gfp_mask) { }
  * memalloc_noio_save - Marks implicit GFP_NOIO allocation scope.
  *
  * This functions marks the beginning of the GFP_NOIO allocation scope.
- * All further allocations will implicitly drop __GFP_IO flag and so
- * they are safe for the IO critical section from the allocation recursion
- * point of view. Use memalloc_noio_restore to end the scope with flags
- * returned by this function.
+ * All further allocations will implicitly drop __GFP_IO and __GFP_FS
+ * flags and so they are safe for both the IO critical section and the
+ * the critical section from the allocation recursion point of view. Use
+ * memalloc_noio_restore to end the scope with flags returned by this
+ * function.
  *
  * This function is safe to be used from any context.
  */
Signature · 1 line
2.21.0
Signature · 2 lines
Michal Hocko
SUSE Labs
author
#2 lore raw
Quoted 11 lines · Michal Hocko
Quoted 7 lines · On Wed 18-09-19 04:58:20, [email protected] wrote:

From: Xiubo Li <[email protected]>

The GFP_NOIO means all further allocations will implicitly drop both __GFP_IO and __GFP_FS flags and so they are safe for both the IO critical section and the the critical section from the allocation recursion point of view. Not only the __GFP_IO, which a bit confusing when reading the code or using the save/restore pair.

Historically GFP_NOIO has always implied GFP_NOFS as well. I can imagine that this might come as an surprise for somebody not familiar with the code though.

Yeah, it true.

Quoted 3 lines

I am wondering whether your update of the documentation
would be better off at __GFP_FS, __GFP_IO resp. GFP_NOFS, GFP_NOIO level. This interface is simply a way to set a scoped NO{IO,FS} context.

The "Documentation/core-api/gfp_mask-from-fs-io.rst" is already very detail about them all.

This fixing just means to make sure that it won't surprise someone who is having a quickly through some code and not familiar much about the detail. It may make not much sense ?

Thanks,
BRs
Xiubo

Quoted 27 lines
Quoted 27 lines
---
  include/linux/sched/mm.h | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)
include/linux/sched/mm.h +5 -4
index 4a7944078cc3..9bdc97e52de1 100644
@@ -211,10 +211,11 @@ static inline void fs_reclaim_release(gfp_t gfp_mask) { }
   * memalloc_noio_save - Marks implicit GFP_NOIO allocation scope.
   *
   * This functions marks the beginning of the GFP_NOIO allocation scope.
- * All further allocations will implicitly drop __GFP_IO flag and so
- * they are safe for the IO critical section from the allocation recursion
- * point of view. Use memalloc_noio_restore to end the scope with flags
- * returned by this function.
+ * All further allocations will implicitly drop __GFP_IO and __GFP_FS
+ * flags and so they are safe for both the IO critical section and the
+ * the critical section from the allocation recursion point of view. Use
+ * memalloc_noio_restore to end the scope with flags returned by this
+ * function.
   *
   * This function is safe to be used from any context.
   */
Signature · 1 line
2.21.0
#3 lore raw
Quoted 19 lines · Xiubo Li
Quoted 11 lines · Michal Hocko
Quoted 7 lines · On Wed 18-09-19 04:58:20, [email protected] wrote:

From: Xiubo Li <[email protected]>

The GFP_NOIO means all further allocations will implicitly drop both __GFP_IO and __GFP_FS flags and so they are safe for both the IO critical section and the the critical section from the allocation recursion point of view. Not only the __GFP_IO, which a bit confusing when reading the code or using the save/restore pair.

Historically GFP_NOIO has always implied GFP_NOFS as well. I can imagine that this might come as an surprise for somebody not familiar with the code though.

Yeah, it true.

Quoted 3 lines

I am wondering whether your update of the documentation
would be better off at __GFP_FS, __GFP_IO resp. GFP_NOFS, GFP_NOIO level. This interface is simply a way to set a scoped NO{IO,FS} context.

Quoted 6 lines

The "Documentation/core-api/gfp_mask-from-fs-io.rst" is already very detail about them all.

This fixing just means to make sure that it won't surprise someone who is having a quickly through some code and not familiar much about the detail. It may make not much sense ?

Ohh, I do not think this would be senseless. I just think that the NOIO implying NOFS as well should be described at the level where they are documented rather than the api you have chosen.

Signature · 2 lines
Michal Hocko
SUSE Labs
author
#4 lore raw
Quoted 21 lines · Michal Hocko
Quoted 20 lines · Xiubo Li
Quoted 11 lines · Michal Hocko
Quoted 7 lines · On Wed 18-09-19 04:58:20, [email protected] wrote:

From: Xiubo Li <[email protected]>

The GFP_NOIO means all further allocations will implicitly drop both __GFP_IO and __GFP_FS flags and so they are safe for both the IO critical section and the the critical section from the allocation recursion point of view. Not only the __GFP_IO, which a bit confusing when reading the code or using the save/restore pair.

Historically GFP_NOIO has always implied GFP_NOFS as well. I can imagine that this might come as an surprise for somebody not familiar with the code though.

Yeah, it true.

Quoted 3 lines

I am wondering whether your update of the documentation
would be better off at __GFP_FS, __GFP_IO resp. GFP_NOFS, GFP_NOIO level. This interface is simply a way to set a scoped NO{IO,FS} context.

The "Documentation/core-api/gfp_mask-from-fs-io.rst" is already very detail about them all.

Quoted 6 lines
Quoted 3 lines

This fixing just means to make sure that it won't surprise someone who is having a quickly through some code and not familiar much about the detail. It may make not much sense ?

Ohh, I do not think this would be senseless. I just think that the NOIO implying NOFS as well should be described at the level where they are documented rather than the api you have chosen.

Hmm, yeah totally agree :-)

Thanks
BRs