@@ -154,7 +154,17 @@ void anon_vma_init(void); /* create anon_vma_cachep */
int __anon_vma_prepare(struct vm_area_struct *);
void unlink_anon_vmas(struct vm_area_struct *);
int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
-int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
+
+int __anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
+static inline int anon_vma_fork(struct vm_area_struct *vma,
+ struct vm_area_struct *pvma)
+{
+ /* Don't bother if the parent process has no anon_vma here. */
+ if (!pvma->anon_vma)
+ return 0;
+
+ return __anon_vma_fork(vma, pvma);
+}
static inline int anon_vma_prepare(struct vm_area_struct *vma)
{
@@ -331,16 +331,12 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
* the corresponding VMA in the parent process is attached to.
* Returns 0 on success, non-zero on failure.
*/
-int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
+int __anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
{
struct anon_vma_chain *avc;
struct anon_vma *anon_vma;
int error;
- /* Don't bother if the parent process has no anon_vma here. */
- if (!pvma->anon_vma)
- return 0;
-
/* Drop inherited anon_vma, we'll reuse existing or allocate new. */
vma->anon_vma = NULL;
Check the anon_vma of pvma inline so we can avoid the function call overhead if the anon_vma is NULL. Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- include/linux/rmap.h | 12 +++++++++++- mm/rmap.c | 6 +----- 2 files changed, 12 insertions(+), 6 deletions(-)