Message ID | 20240220231424.126600-2-vishal.moola@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-73812-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp720134dyc; Tue, 20 Feb 2024 15:18:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUOHZSNCmuWFzp2qSuKH+6kbJ/VV3mcVp9u83JyPIqjE43pTXbsZ8OvvenMRMI3QC2mZHY1bI4aaQqfMpXkR7ZcwsYkog== X-Google-Smtp-Source: AGHT+IEpMz90K9pe67nkWa0yUJJ1rBZ5rd99fpnyE0v6uFs9bSGAfvgq0/v5Oa+KIY1HKmModWSM X-Received: by 2002:a17:906:c347:b0:a3e:c6de:e5bb with SMTP id ci7-20020a170906c34700b00a3ec6dee5bbmr5331194ejb.40.1708471113019; Tue, 20 Feb 2024 15:18:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708471113; cv=pass; d=google.com; s=arc-20160816; b=FM4aXmwdIEq5BD472NpqsdLsrPW9Vdt3XtLjnEtUXaFOZB+Tx5fjALoP/JheDT9IFG DLgiS8TzGJbqLOro1mIC82C0e4UboN7tSZHDmFqRz0LGoDTfkA2tIBOOjyB09vxuDVLc XJBwrKdMNxsfQe4RNrZaIPlSijIv55hqixb7J49eOg4O8ePnwQVvDFLg86PLRV6HJMbZ tUlCiGZEWdbtBsVwuXliIaB/A/2at0qeSwB5Mze1g8VGO+P2A70IgdBTiUgcGKRmrBiN z0hLSNVqBJVGpjFAJspSQ/r/0Nrov+6uQG+0GDvc5r0KNXnx5tEJu2BMp88ofGTcLxh4 GYAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BBH3LTjaBMSoYxUwPuTSep1EAb5H3OicE1Nmx6szstY=; fh=g4N4lZkFGOQs9eZ+YhR5V4YGLRojpV4hZZzrx8OfUSs=; b=S73mos0vHOtr6v9ATQ5oFXNNSiz9+iRyEyKMFOI8Sys6ZCXRwQO8Cu5RmnjvCeuB8c IMTejQCp1xEZ62G0LFZVyG/ciGczMRvMQurHYHN8pgiSn3uokZxoDTVF/nCZbLKTI6eC k7x3igVLQUFPHsT6ebmJe1dZvLY00DAmZL5f9FNRu1nsEo0WrMyGIWt2+FHDEKRpeXH7 keWbirqrkf+hXdGsy+EVs9zgxP+0Lj63fhNUp7bgHGPxvafAeLT91VB2Ot1hg4bFRUIz SEPnJelE4Gs+ha9aKdEDfuM4GmmOiEezYW+xf6P3y+LsQuvBBGSK2cSTXNI/1EfE5wut 3r6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mQLaX7vl; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-73812-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73812-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f26-20020a1709062c5a00b00a3e91fccd17si2277787ejh.154.2024.02.20.15.18.32 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 15:18:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73812-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mQLaX7vl; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-73812-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73812-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9EE9A1F22FC0 for <ouuuleilei@gmail.com>; Tue, 20 Feb 2024 23:18:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B5C976C99; Tue, 20 Feb 2024 23:18:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mQLaX7vl" Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80C5813667B for <linux-kernel@vger.kernel.org>; Tue, 20 Feb 2024 23:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708471077; cv=none; b=Z1tbDA/ev1FR5hxtDh/VNMZeOst5o4gOVTXJk/gxz5iBQHm3dY1oR46ktQGThDwMBZUF+5gNC3/RlzTlBt4o54LuDjsRWue4g5DstWRXx7WbIZAo4oeXze8k/Y4gfQ/cb8hqmC+PSMu3vWGENNblTgPD3Y9nVKy9gjITwUmG3kE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708471077; c=relaxed/simple; bh=yqsbw6iQdZTVB2cYQu2elIu0K2UeUBgcZazLloZTOHE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z7IROXxa45S5Gfl+mMb38vWEC6nXdyMuyelRdkKOYmJclpi1iSr1mG59TteiTgbnLbvmua+8a9RU60iqH40D7Gt+aO1HokebPOeT5Zdj34E6Tk1hc85pC5Qg6BgPkyWlSFhh5QVRyxV/2BuP3Z+KR8LF6hS3eTIcmf2W5YqcKWU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mQLaX7vl; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6e43ee3f6fbso3045810b3a.3 for <linux-kernel@vger.kernel.org>; Tue, 20 Feb 2024 15:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708471076; x=1709075876; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BBH3LTjaBMSoYxUwPuTSep1EAb5H3OicE1Nmx6szstY=; b=mQLaX7vlg2cyb+ishtPrBoSFpqrI2WwABZ8omrC5LJya8fwbfPtMou4MGa9s++ksHn PoCuDEE1ffL5DKxDDzGq/4eaTqznhldh8CckBrs0Xx8vnO6/LM74SSqO+piqULGD3PRW o+DiP+0lENwhzYq08Qqru3svzF9vZJcP2BU8D47Ww0c1VO5UnXPu1OXP2Tz1FC4VRgUX jQHQxVJ8JuZWpsCo92xE8vjWvHRh9LiUyteK/tR5I63CK3GobVgxiEJ+sCtCHb6SEFEw b9/F6GZKqiTUHAsOGTcugi/pLbAn1mWvp/qdEJ11l26lOtEtKpPfPIqydOX7HBAX0fG+ rwEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708471076; x=1709075876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BBH3LTjaBMSoYxUwPuTSep1EAb5H3OicE1Nmx6szstY=; b=CLglZ9eeYuI/Jx/GsDalFcGMNdCUu1Vea+FQVPC7myfS4jDijn5UI8gZEM5QwKTjmG zrsYxVj8RVYXFli6sgnae9kS+kLVTYo9/4mR9IfylroKykBu9gYiIGYR4B+VInWZtwF7 gZuknv+Ash4ua/J+cOxjsy2gVA723WZ00mYRlqWGZZ4Qjwy5UDO21q8uSVnWzWTNR/H2 w5Vs/E1HBf9iOqjpd3eqe5tg0dpNtIgrH8gl77WhrZ5Za2uBF7XjzOrER7gjvcxOo1S4 8hS9fVHYLdFTX5aO/o25I0m4ILuDbdlpXBYagOXyI1A67dFGIHYEFogz/ZnsikxiwlGH Sp0g== X-Gm-Message-State: AOJu0Yzx/z0o7F4FgkfbXi516MQfv8EBjYseUja9EX//G7F/YS0WNfLI btMIVdGXFHYVj7OL7nYpXh+9zCb4/HVkI/Rg47NmQn2tuWxwF627 X-Received: by 2002:a62:c312:0:b0:6e1:338d:e01c with SMTP id v18-20020a62c312000000b006e1338de01cmr13801818pfg.1.1708471075876; Tue, 20 Feb 2024 15:17:55 -0800 (PST) Received: from fedora.. (c-73-170-51-167.hsd1.ca.comcast.net. [73.170.51.167]) by smtp.googlemail.com with ESMTPSA id x16-20020aa784d0000000b006e13a5ab1e5sm5317803pfn.73.2024.02.20.15.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 15:17:55 -0800 (PST) From: "Vishal Moola (Oracle)" <vishal.moola@gmail.com> To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, muchun.song@linux.dev, "Vishal Moola (Oracle)" <vishal.moola@gmail.com> Subject: [PATCH 1/3] mm/memory: Change vmf_anon_prepare() to be non-static Date: Tue, 20 Feb 2024 15:14:22 -0800 Message-ID: <20240220231424.126600-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240220231424.126600-1-vishal.moola@gmail.com> References: <20240220231424.126600-1-vishal.moola@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791461805762290424 X-GMAIL-MSGID: 1791461805762290424 |
Series |
Handle hugetlb faults under the VMA lock
|
|
Commit Message
Vishal Moola
Feb. 20, 2024, 11:14 p.m. UTC
In order to handle hugetlb faults under the VMA lock, hugetlb can use
vmf_anon_prepare() to ensure we can safely prepare an anon_vma. Change
it to be a non-static function so it can be used within hugetlb as well.
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
---
include/linux/hugetlb.h | 1 +
mm/memory.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
Comments
On Tue, Feb 20, 2024 at 03:14:22PM -0800, Vishal Moola (Oracle) wrote: > In order to handle hugetlb faults under the VMA lock, hugetlb can use > vmf_anon_prepare() to ensure we can safely prepare an anon_vma. Change > it to be a non-static function so it can be used within hugetlb as well. I think the prototype for this should probably live in mm/internal.h? > +++ b/include/linux/hugetlb.h > @@ -272,6 +272,7 @@ void hugetlb_vma_unlock_write(struct vm_area_struct *vma); > int hugetlb_vma_trylock_write(struct vm_area_struct *vma); > void hugetlb_vma_assert_locked(struct vm_area_struct *vma); > void hugetlb_vma_lock_release(struct kref *kref); > +vm_fault_t vmf_anon_prepare(struct vm_fault *vmf); > > int pmd_huge(pmd_t pmd); > int pud_huge(pud_t pud); >
On Tue, Feb 20, 2024 at 7:36 PM Matthew Wilcox <willy@infradead.org> wrote: > > On Tue, Feb 20, 2024 at 03:14:22PM -0800, Vishal Moola (Oracle) wrote: > > In order to handle hugetlb faults under the VMA lock, hugetlb can use > > vmf_anon_prepare() to ensure we can safely prepare an anon_vma. Change > > it to be a non-static function so it can be used within hugetlb as well. > > I think the prototype for this should probably live in mm/internal.h? That does make more sense, I'll move it for v2. > > +++ b/include/linux/hugetlb.h > > @@ -272,6 +272,7 @@ void hugetlb_vma_unlock_write(struct vm_area_struct *vma); > > int hugetlb_vma_trylock_write(struct vm_area_struct *vma); > > void hugetlb_vma_assert_locked(struct vm_area_struct *vma); > > void hugetlb_vma_lock_release(struct kref *kref); > > +vm_fault_t vmf_anon_prepare(struct vm_fault *vmf); > > > > int pmd_huge(pmd_t pmd); > > int pud_huge(pud_t pud); > >
Hi Vishal, kernel test robot noticed the following build warnings: [auto build test WARNING on akpm-mm/mm-everything] [also build test WARNING on linus/master v6.8-rc5 next-20240221] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Vishal-Moola-Oracle/mm-memory-Change-vmf_anon_prepare-to-be-non-static/20240221-071907 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20240220231424.126600-2-vishal.moola%40gmail.com patch subject: [PATCH 1/3] mm/memory: Change vmf_anon_prepare() to be non-static config: arm-defconfig (https://download.01.org/0day-ci/archive/20240222/202402220109.SIlFdfQ5-lkp@intel.com/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240222/202402220109.SIlFdfQ5-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202402220109.SIlFdfQ5-lkp@intel.com/ All warnings (new ones prefixed by >>): >> mm/memory.c:3283:12: warning: no previous prototype for function 'vmf_anon_prepare' [-Wmissing-prototypes] vm_fault_t vmf_anon_prepare(struct vm_fault *vmf) ^ mm/memory.c:3283:1: note: declare 'static' if the function is not intended to be used outside of this translation unit vm_fault_t vmf_anon_prepare(struct vm_fault *vmf) ^ static 1 warning generated. vim +/vmf_anon_prepare +3283 mm/memory.c 3282 > 3283 vm_fault_t vmf_anon_prepare(struct vm_fault *vmf) 3284 { 3285 struct vm_area_struct *vma = vmf->vma; 3286 3287 if (likely(vma->anon_vma)) 3288 return 0; 3289 if (vmf->flags & FAULT_FLAG_VMA_LOCK) { 3290 vma_end_read(vma); 3291 return VM_FAULT_RETRY; 3292 } 3293 if (__anon_vma_prepare(vma)) 3294 return VM_FAULT_OOM; 3295 return 0; 3296 } 3297
Hi Vishal, kernel test robot noticed the following build warnings: [auto build test WARNING on akpm-mm/mm-everything] [also build test WARNING on linus/master v6.8-rc5 next-20240221] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Vishal-Moola-Oracle/mm-memory-Change-vmf_anon_prepare-to-be-non-static/20240221-071907 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20240220231424.126600-2-vishal.moola%40gmail.com patch subject: [PATCH 1/3] mm/memory: Change vmf_anon_prepare() to be non-static config: alpha-allnoconfig (https://download.01.org/0day-ci/archive/20240222/202402220352.930oDAQ6-lkp@intel.com/config) compiler: alpha-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240222/202402220352.930oDAQ6-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202402220352.930oDAQ6-lkp@intel.com/ All warnings (new ones prefixed by >>): >> mm/memory.c:3283:12: warning: no previous prototype for 'vmf_anon_prepare' [-Wmissing-prototypes] 3283 | vm_fault_t vmf_anon_prepare(struct vm_fault *vmf) | ^~~~~~~~~~~~~~~~ vim +/vmf_anon_prepare +3283 mm/memory.c 3282 > 3283 vm_fault_t vmf_anon_prepare(struct vm_fault *vmf) 3284 { 3285 struct vm_area_struct *vma = vmf->vma; 3286 3287 if (likely(vma->anon_vma)) 3288 return 0; 3289 if (vmf->flags & FAULT_FLAG_VMA_LOCK) { 3290 vma_end_read(vma); 3291 return VM_FAULT_RETRY; 3292 } 3293 if (__anon_vma_prepare(vma)) 3294 return VM_FAULT_OOM; 3295 return 0; 3296 } 3297
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index c1ee640d87b1..9b45edb6e303 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -272,6 +272,7 @@ void hugetlb_vma_unlock_write(struct vm_area_struct *vma); int hugetlb_vma_trylock_write(struct vm_area_struct *vma); void hugetlb_vma_assert_locked(struct vm_area_struct *vma); void hugetlb_vma_lock_release(struct kref *kref); +vm_fault_t vmf_anon_prepare(struct vm_fault *vmf); int pmd_huge(pmd_t pmd); int pud_huge(pud_t pud); diff --git a/mm/memory.c b/mm/memory.c index 89bcae0b224d..c93b058adfb2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3081,7 +3081,7 @@ static inline vm_fault_t vmf_can_call_fault(const struct vm_fault *vmf) return VM_FAULT_RETRY; } -static vm_fault_t vmf_anon_prepare(struct vm_fault *vmf) +vm_fault_t vmf_anon_prepare(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma;