Message ID | 8ecffbf990afd1c8ccc195a2ec321d55f0923908.1733305182.git.zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFFF1E7716D for <linux-mm@archiver.kernel.org>; Wed, 4 Dec 2024 11:11:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76C1B6B0099; Wed, 4 Dec 2024 06:11:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 719CF6B009A; Wed, 4 Dec 2024 06:11:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BA736B009B; Wed, 4 Dec 2024 06:11:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3C78A6B0099 for <linux-mm@kvack.org>; Wed, 4 Dec 2024 06:11:00 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E8209160F78 for <linux-mm@kvack.org>; Wed, 4 Dec 2024 11:10:59 +0000 (UTC) X-FDA: 82857008808.19.07B6345 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf30.hostedemail.com (Postfix) with ESMTP id C1A618000D for <linux-mm@kvack.org>; Wed, 4 Dec 2024 11:10:30 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Tm2TFRIG; spf=pass (imf30.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733310643; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QkuROlRprAHSTBsp8RZw3I2mnycKFd5DDkO/yWw4n1g=; b=fjflhPyegNw/MLGRc8TiVosmqZ9piCVCuOHFn+v365wk5ucyYelvegQHvIMTmFWLYnkS7k ISm9hWpQSEmBF/EDDHKhiqMSdJoRiDJdoBXpRmU76WWADrh5Tm71wLNEBq5z78cDIqOZmd Ov6OGVoVmJL44FMPwLbCR5qMzEEt5Nc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733310643; a=rsa-sha256; cv=none; b=b2HGNiGrtoAV9fJQpWzaH/BtwuJsuiCliie5Aimkx7AnQ2wii2mRVsJtQJPTVfh1ni96Sp 8WBOGHTZyDDagA7VVYfYCIWD4oEVlxxC82trorJEGrt36yoWyO+iiZtzzS+tjth8aNeMfE gf4Xvq6wkcQ6TCPfXHzlsvflZgxCQMo= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=Tm2TFRIG; spf=pass (imf30.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2155312884fso50283375ad.0 for <linux-mm@kvack.org>; Wed, 04 Dec 2024 03:10:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1733310656; x=1733915456; darn=kvack.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=QkuROlRprAHSTBsp8RZw3I2mnycKFd5DDkO/yWw4n1g=; b=Tm2TFRIGYdw91S11nahO+qQd3aE1uTYqrpl2OegHszHwzXpMWZVsTwHg9Y+64kR+jy swUCcS8U+DyqI2S0bIiXKyrUxKyL08dTgWdsHaUWYlIjVKuW+gma02FonEkPZxxqKaFX qLXpDq4arLuqgryB9W0OrTyIiXtylua9Sk5A79fnncJpEXScXHtUvyZmpYHFxzzoDRSK Vdy5ODhOIiGCTK73aM2MX9aAsI/KHALcVGeadSvGiv7IxdFDgvzb5Fl5Cdu3I7dJknRM Hc5wr0DXNj+DojUt0QnXcLfhp545m6Ux22dB8CLfawfC8xvOT4BXsdLXgUVVMcmv6FU1 0C1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733310656; x=1733915456; 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=QkuROlRprAHSTBsp8RZw3I2mnycKFd5DDkO/yWw4n1g=; b=EKyQ56QfpTwEk1mVc5IumUuhipKqHGIiE9LdYf0h2Co800cqAHNQUHnvWU0Fs7Vkco O0kXxyAwj9XQipj75UKoONhczdku0tUIwpg3o9jpSGsaGLy105ivI1yriNi2TI23Y4og Cl9//NtFIGN8qBOYvNUxk/doP2Pn0TiQsJDFvouHR18N2t2A1Q3FKTWgCUAmTnFnEZOK 7GCKcvgBymk/iCRS0QS6GlujEy2XlA3jbrcZpmdrVhQxkh1ad9KoUVtGf/1VR/RHBei1 3rg9BGC5IOxW+UAADPrJfXgV4SfB98bjp15OkZuPvdxSpgXdskFTSYfryrSd6W4NCxDM M9NQ== X-Forwarded-Encrypted: i=1; AJvYcCVQzMOnee/m/weA83OJrWC0asErk+BrHcnD6bwdhC3h6QrKbmGumOk9OosorGLLc0GUIYdQekgMlg==@kvack.org X-Gm-Message-State: AOJu0YzOVfn/tz/RyJK/l3vD7Zjjy+bV/suNlytdawjv63xf/LjD9x4B /hwzSy+w6wJLxPbF4KYjccaRFFd+eo3cpSpRuW/UEjJc5aMQ7PlOHF8IdWjDEHQ= X-Gm-Gg: ASbGncuBJXlw3i3Kbt/9a2Ox8rUqwroxa/eIYLCCAbD3OCkzjERW2vGWxvFwhYHIUBk kXyjE64L+by9nh+/sMjWiEirFw7S29Gm0rH5BkMLNHErMvL3VdMpgTpK0+Y22H2NSk5fnO0BguH DBmCYsyAlkp44E1WUk5u0b13L/cUZYqe9F0Oytz9HLPP2BRJ3IqzNNThkUA8utAJa5rNAYr9l9K +AJ4NUi+iRd650pi2V7mzw6KCAqmnEJKP4S2U0UY8L0Wo5P9xno1Ar6Opi5iMxycf+hIeELkhWj BfDtL9gS+8dnVbM= X-Google-Smtp-Source: AGHT+IEu/5U9u+MTuBZhWK2lULLFn2ChhXdgNwcwoaBBrqVb6T6ZJFfs9ziJlEdo4kgFVcC+MHm1Dw== X-Received: by 2002:a17:902:dac7:b0:215:72aa:693f with SMTP id d9443c01a7336-215bd1b476emr75201455ad.9.1733310656657; Wed, 04 Dec 2024 03:10:56 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.148]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21527515731sm107447495ad.192.2024.12.04.03.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 03:10:55 -0800 (PST) From: Qi Zheng <zhengqi.arch@bytedance.com> To: david@redhat.com, jannh@google.com, hughd@google.com, willy@infradead.org, muchun.song@linux.dev, vbabka@kernel.org, peterx@redhat.com, akpm@linux-foundation.org Cc: mgorman@suse.de, catalin.marinas@arm.com, will@kernel.org, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, x86@kernel.org, lorenzo.stoakes@oracle.com, zokeefe@google.com, rientjes@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng <zhengqi.arch@bytedance.com> Subject: [PATCH v4 05/11] mm: skip over all consecutive none ptes in do_zap_pte_range() Date: Wed, 4 Dec 2024 19:09:45 +0800 Message-Id: <8ecffbf990afd1c8ccc195a2ec321d55f0923908.1733305182.git.zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <cover.1733305182.git.zhengqi.arch@bytedance.com> References: <cover.1733305182.git.zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C1A618000D X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: ccq348toa7gna48ku7mbmgefcydc8owy X-HE-Tag: 1733310630-950930 X-HE-Meta: U2FsdGVkX19hQdEY1y5KVDFribXgd/UxsEWMGOseYFuDRvDIZFhkgxp35qvBWakm09uYfomOZa+WvVgWX8fxoZL2PzhKeOmumgg4zixPescBT+yny32pFuvbMmeQZ2Wnd1nsPEcEXFD3ePPix7evax8nviaGAxTIQ3GqGDQJSdI/DzGo1j7DKvdMRNKFj81LFLSKY1a55dobJ5IVcQ7b0rhMkIr7YmvpYVG++uzvh00vUG6LZQ/PUDkIcNxhL6vzZ22rrcgAPvAvokPcWks5VSBB4O014TexKawupGKkZw8ywNMqlLSpCaiQR3hqloU4llD4gYksv96UBVrgaLcJH5AxV2wgYxab9uhCcPQsZgGsXbW53rP9UuMAZPWrFlsD6QCPb9PsJOucN6WNrLF8CaXyP0W6Uoz/EUF7Sh4lfBVEvOOLF1nlYt3nYE2Q9zwK2kDbMi3646b443oTVgwOAI75ddzo74WyEDiGPwJNZDag6n6o3Sxnq77WTOdGPf8EIp/VYTiEJu7/W+fyP9MP6D0ep/5SUOG4xbo4I0x3GF+kH2YBserozl79sV8wgxMxyqC2eC/Ny1T3d97y5ZuB/Hl0pA6KiWVbYB/CBpkjjMSv6nJBY7vFjCv+EiNvYShVVLaw/GhKEPBt/i6WIJOSfNnXtx0f8qM+/tbk8hLp4uNt09YIG4BhSnetE2Dh4vsWjUT0Z9tqgsThoVA59g+6gfwOlctbG0q/v+2v7qWSjYkYkoAf3o4z37bOVO9plW9lrO8JqUFKQtCstUJjgM25fDdY46Hx9dzRhkMBKYYdejlNWmBcHyuLTibNnvU4ip9zQgkD4Lc4RnaPoD3VsOLIT3F+1fnPp5KHQW2LSDBOpr4myL0Ow8KMuPC2UkuryG0aSMyKaPNPShZfv9hG7RVgoTIpoYR/X0rd41R6fRZ0D6uSkINhcYkYgDBgFGh09EqTV95zaAXYPTWZnE+XgIZ H4gCiVX7 iaRsxxMX11881pG96794Ef2s3bD1KPOiuhlMB4uMD02IBbnGjJT4TTkkIfUKTtS4o4efCeIXeWHQSRWTxCg70OWzntvNdfrimOLPcdOM2wuOsXQC34dsXEgGGjUhu33xZHPpIalwLGx4nRuRtzMlyG2TLJyCd7jCAoMFUSX+T6saZl1yKvPCyHfxLFrcpQTTvPdK8uKywBYPXJ3FfqiiUb6/8U9ffTFXMRn5DxnWRwnIgWFfDFPESpHelUzhn2B26YFbBHJgfR87WxJtOL5oXULiooAf0y1l387yFMADfJg1sEmMRdk7qT587WxP5q2Vgdu+8tDsqyd/bQQU7uEkG534FMtWH5dmzyiQWwp0hY38LjqMSiwmetIPakn1aBH43AbpL X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
synchronously scan and reclaim empty user PTE pages
|
expand
|
diff --git a/mm/memory.c b/mm/memory.c index abe07e6bdd1bb..7f8869a22b57c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1665,17 +1665,30 @@ static inline int do_zap_pte_range(struct mmu_gather *tlb, { pte_t ptent = ptep_get(pte); int max_nr = (end - addr) / PAGE_SIZE; + int nr = 0; - if (pte_none(ptent)) - return 1; + /* Skip all consecutive none ptes */ + if (pte_none(ptent)) { + for (nr = 1; nr < max_nr; nr++) { + ptent = ptep_get(pte + nr); + if (!pte_none(ptent)) + break; + } + max_nr -= nr; + if (!max_nr) + return nr; + pte += nr; + addr += nr * PAGE_SIZE; + } if (pte_present(ptent)) - return zap_present_ptes(tlb, vma, pte, ptent, max_nr, - addr, details, rss, force_flush, - force_break); + nr += zap_present_ptes(tlb, vma, pte, ptent, max_nr, addr, + details, rss, force_flush, force_break); + else + nr += zap_nonpresent_ptes(tlb, vma, pte, ptent, max_nr, addr, + details, rss); - return zap_nonpresent_ptes(tlb, vma, pte, ptent, max_nr, addr, - details, rss); + return nr; } static unsigned long zap_pte_range(struct mmu_gather *tlb,
Skip over all consecutive none ptes in do_zap_pte_range(), which helps optimize away need_resched() + force_break + incremental pte/addr increments etc. Suggested-by: David Hildenbrand <david@redhat.com> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> --- mm/memory.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)