Skip to contentSkip to conversation

mm: Change return type to vm_fault_t

PATCH Superseded Souptick Joarder 4 participants 8 messages May 12, 2018 – May 13, 2018

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 mm: Change return type to vm_fault_t

Use new return type vm_fault_t for fault handler in struct vm_operations_struct. For now, this is just documenting that the function returns a VM_FAULT value rather than an errno. Once all instances are converted, vm_fault_t will become a distinct type.

commit 1c8f422059ae ("mm: change return type to vm_fault_t")

---
v2: updated the change log

v3: added <linux/mm_types.h> changes
into the same patch

 include/linux/mm_types.h | 2 +-
 mm/hugetlb.c             | 2 +-
 mm/mmap.c                | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
include/linux/mm_types.h +1 -1
index 2161234..11acfdb 100644
@@ -627,7 +627,7 @@ struct vm_special_mapping {
 	 * If non-NULL, then this is called to resolve page faults
 	 * on the special mapping.  If used, .pages is not checked.
 	 */
-	int (*fault)(const struct vm_special_mapping *sm,
+	vm_fault_t (*fault)(const struct vm_special_mapping *sm,
 		     struct vm_area_struct *vma,
 		     struct vm_fault *vmf);
 
mm/hugetlb.c +1 -1
index 2186791..7e00bd3 100644
@@ -3159,7 +3159,7 @@ static unsigned long hugetlb_vm_op_pagesize(struct vm_area_struct *vma)
  * hugegpage VMA.  do_page_fault() is supposed to trap this, so BUG is we get
  * this far.
  */
-static int hugetlb_vm_op_fault(struct vm_fault *vmf)
+static vm_fault_t hugetlb_vm_op_fault(struct vm_fault *vmf)
 {
 	BUG();
 	return 0;
mm/mmap.c +2 -2
index 188f195..bdd4ba9a 100644
@@ -3228,7 +3228,7 @@ void vm_stat_account(struct mm_struct *mm, vm_flags_t flags, long npages)
 		mm->data_vm += npages;
 }
 
-static int special_mapping_fault(struct vm_fault *vmf);
+static vm_fault_t special_mapping_fault(struct vm_fault *vmf);
 
 /*
  * Having a close hook prevents vma merging regardless of flags.
@@ -3267,7 +3267,7 @@ static int special_mapping_mremap(struct vm_area_struct *new_vma)
 	.fault = special_mapping_fault,
 };
 
-static int special_mapping_fault(struct vm_fault *vmf)
+static vm_fault_t special_mapping_fault(struct vm_fault *vmf)
 {
 	struct vm_area_struct *vma = vmf->vma;
 	pgoff_t pgoff;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 6 lines · Souptick Joarder

Use new return type vm_fault_t for fault handler in struct vm_operations_struct. For now, this is just documenting that the function returns a VM_FAULT value rather than an errno. Once all instances are converted, vm_fault_t will become a distinct type.

trivia:

include/linux/mm_types.h

Quoted 1 line
include/linux/mm_types.h +0 -0

[]

include/linux/mm_types.h struct vm_special_mapping { · line 632

Quoted 8 lines
include/linux/mm_types.h +1 -1
@@ -627,7 +627,7 @@ struct vm_special_mapping {
 	 * If non-NULL, then this is called to resolve page faults
 	 * on the special mapping.  If used, .pages is not checked.
 	 */
-	int (*fault)(const struct vm_special_mapping *sm,
+	vm_fault_t (*fault)(const struct vm_special_mapping *sm,
 		     struct vm_area_struct *vma,
 		     struct vm_fault *vmf);

It'd be nicer to realign the 2nd and 3rd arguments on the subsequent lines.

vm_fault_t (*fault)(const struct vm_special_mapping *sm,
struct vm_area_struct *vma, struct vm_fault *vmf);

#2 lore raw
Quoted 25 lines · Joe Perches
Quoted 6 lines · Souptick Joarder

Use new return type vm_fault_t for fault handler in struct vm_operations_struct. For now, this is just documenting that the function returns a VM_FAULT value rather than an errno. Once all instances are converted, vm_fault_t will become a distinct type.

trivia:

include/linux/mm_types.h

Quoted 1 line
include/linux/mm_types.h +0 -0

[]

include/linux/mm_types.h struct vm_special_mapping { · line 632

Quoted 8 lines
include/linux/mm_types.h +1 -1
@@ -627,7 +627,7 @@ struct vm_special_mapping {
       * If non-NULL, then this is called to resolve page faults
       * on the special mapping.  If used, .pages is not checked.
       */
-     int (*fault)(const struct vm_special_mapping *sm,
+     vm_fault_t (*fault)(const struct vm_special_mapping *sm,
                   struct vm_area_struct *vma,
                   struct vm_fault *vmf);

It'd be nicer to realign the 2nd and 3rd arguments on the subsequent lines.

Quoted 4 lines

vm_fault_t (*fault)(const struct vm_special_mapping *sm,
struct vm_area_struct *vma, struct vm_fault *vmf);

Just now posted v3. Do you want me to send v4 again with realignment ?

#3 lore raw
Quoted 26 lines · Souptick Joarder
Quoted 25 lines · Joe Perches
Quoted 6 lines · Souptick Joarder

Use new return type vm_fault_t for fault handler in struct vm_operations_struct. For now, this is just documenting that the function returns a VM_FAULT value rather than an errno. Once all instances are converted, vm_fault_t will become a distinct type.

trivia:

include/linux/mm_types.h

Quoted 1 line
include/linux/mm_types.h +0 -0

[]

include/linux/mm_types.h struct vm_special_mapping { · line 632

Quoted 8 lines
include/linux/mm_types.h +1 -1
@@ -627,7 +627,7 @@ struct vm_special_mapping {
       * If non-NULL, then this is called to resolve page faults
       * on the special mapping.  If used, .pages is not checked.
       */
-     int (*fault)(const struct vm_special_mapping *sm,
+     vm_fault_t (*fault)(const struct vm_special_mapping *sm,
                   struct vm_area_struct *vma,
                   struct vm_fault *vmf);

It'd be nicer to realign the 2nd and 3rd arguments on the subsequent lines.

Quoted 7 lines
Quoted 4 lines

vm_fault_t (*fault)(const struct vm_special_mapping *sm,
struct vm_area_struct *vma, struct vm_fault *vmf);

Just now posted v3. Do you want me to send v4 again with realignment ?

Sorry, please ignore this mail.

#4 lore raw
In reply to Joe Perches
Quoted 7 lines · Joe Perches

It'd be nicer to realign the 2nd and 3rd arguments on the subsequent lines.

vm_fault_t (*fault)(const struct vm_special_mapping *sm,
struct vm_area_struct *vma, struct vm_fault *vmf);

It'd be nicer if people didn't try to line up arguments at all and just indented by an extra two tabs when they had to break a logical line due to the 80-column limit.

#5 lore raw
Quoted 10 lines
Quoted 8 lines

It'd be nicer to realign the 2nd and 3rd arguments on the subsequent lines.

vm_fault_t (*fault)(const struct vm_special_mapping *sm,
struct vm_area_struct *vma, struct vm_fault *vmf);

Quoted 3 lines

It'd be nicer if people didn't try to line up arguments at all and just indented by an extra two tabs when they had to break a logical line due to the 80-column limit.

Matthew, there are two different opinions. Which one to take ?

#6 lore raw
Quoted 10 lines · Souptick Joarder
Quoted 9 lines
Quoted 8 lines

It'd be nicer to realign the 2nd and 3rd arguments on the subsequent lines.

vm_fault_t (*fault)(const struct vm_special_mapping *sm,
struct vm_area_struct *vma, struct vm_fault *vmf);

Quoted 5 lines
Quoted 3 lines

It'd be nicer if people didn't try to line up arguments at all and just indented by an extra two tabs when they had to break a logical line due to the 80-column limit.

Matthew, there are two different opinions. Which one to take ?

Unfortunately this is one of those "maintainer's choice" preferences that drives new contributors crazy. Just go with the two tabs like Matthew said and be done.

#7 lore raw
Quoted 12 lines · Dan Williams
Quoted 11 lines · Souptick Joarder
Quoted 10 lines
Quoted 7 lines

It'd be nicer to realign the 2nd and 3rd arguments on the subsequent lines.

vm_fault_t (*fault)(const struct vm_special_mapping *sm,
struct vm_area_struct *vma, struct vm_fault *vmf);

It'd be nicer if people didn't try to line up arguments at all and just indented by an extra two tabs when they had to break a logical line due to the 80-column limit.

Quoted 5 lines
Quoted 1 line

Matthew, there are two different opinions. Which one to take ?

Unfortunately this is one of those "maintainer's choice" preferences that drives new contributors crazy. Just go with the two tabs like Matthew said and be done.

The only reason I mentioned it was the old function name was aligned that way with arguments aligned to the open parenthesis.

Renaming the function should keep the same alignment style and not just rename the function.

- int (*fault)(const struct vm_special_mapping *sm,
+ vm_fault_t (*fault)(const struct vm_special_mapping *sm,
struct vm_area_struct *vma,
struct vm_fault *vmf);

Here the previous indent was 2 tabs, 5 spaces