From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 21D12FA3740 for ; Mon, 31 Oct 2022 09:46:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 953D36B0071; Mon, 31 Oct 2022 05:46:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88E8F6B0073; Mon, 31 Oct 2022 05:46:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72F716B0074; Mon, 31 Oct 2022 05:46:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 47CCA6B0071 for ; Mon, 31 Oct 2022 05:46:29 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D4B6E1A0C24 for ; Mon, 31 Oct 2022 09:46:28 +0000 (UTC) X-FDA: 80080764456.05.8804A88 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf09.hostedemail.com (Postfix) with ESMTP id CCD51140004 for ; Mon, 31 Oct 2022 09:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=1LT+IJGInDBKkqvcdSfAEMexu/jCj7/5OuTrYDg+YBU=; b=T+O8w0UHsM1MpLqWjLZ8/z4VUI OIVLI+IW6IihMaAOgTZyWUAgD5SyrUHXsfwJ5QpCA4YxU0hCroC028vVuDZ3ef/Mo1qL1RPAZI8LO Ir7yEodRBItmQBys8sO719TJHFA8GspYbb865wMTLnuXIc/KlkF+ZteoP/SovAWFXq+Fk/bwrM7VD L8yEyp/Kh0UNVQ75nl2l92Yb/oXzBW7kI6nUE5k4ebynSomQp5MzDOE/kqxqAnkcaCMe/HUjxeskF /+AoHBEMhUlSCgQH6bHQb/KmFPHrq+hPgTOw29N7KoJ7NI+65aQsGqmN3ShkHrO+8JMi55NwBAuAP I4wr/RxQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1opRN1-007q4D-Gh; Mon, 31 Oct 2022 09:46:16 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id AEE6C30010B; Mon, 31 Oct 2022 10:46:14 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 93B6F2B9C3936; Mon, 31 Oct 2022 10:46:14 +0100 (CET) Date: Mon, 31 Oct 2022 10:46:14 +0100 From: Peter Zijlstra To: Linus Torvalds Cc: Nadav Amit , Jann Horn , John Hubbard , X86 ML , Matthew Wilcox , Andrew Morton , kernel list , Linux-MM , Andrea Arcangeli , "Kirill A . Shutemov" , jroedel@suse.de, ubizjak@gmail.com, Alistair Popple Subject: Re: [PATCH 01/13] mm: Update ptep_get_lockless()s comment Message-ID: References: <47678198-C502-47E1-B7C8-8A12352CDA95@gmail.com> <140B437E-B994-45B7-8DAC-E9B66885BEEF@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=T+O8w0UH; spf=none (imf09.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667209588; a=rsa-sha256; cv=none; b=ilun8kfs31/yO7Z9ongUjBXf+aSNRTr0QnH/U9EnqB3JDc9N8ZQ97fJZczYz6GHd8s2e6N lnQAGSwFo15bweDYFxMpCTDsS+6FMANB2tb3xboEdaOUquDY0p6QMz01ZTWLO22WVK8GFq Nvcqg1SQgijwyzQVpkxO18L40uXBozM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667209588; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1LT+IJGInDBKkqvcdSfAEMexu/jCj7/5OuTrYDg+YBU=; b=3P4Umxmx7KNvWhhvL0VzIxryncdiGsnMNABHPZHkRKta3V87ihRyJzLZXSllDxRjcqpeDr md+dIWstIyye/wYHDnY0Lf33QSEO6OgAethZsYdgitWyKRSnbgO26BHfc84oeROMnIKvh8 7PBqf8i75wst2z9nuZs5oW0nmA4zZYc= X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=T+O8w0UH; spf=none (imf09.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none X-Rspamd-Server: rspam07 X-Stat-Signature: 89gica6rdgbr8fjj48q336h4xy9zg4dn X-Rspamd-Queue-Id: CCD51140004 X-HE-Tag: 1667209587-213121 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: On Sun, Oct 30, 2022 at 06:47:23PM -0700, Linus Torvalds wrote: > diff --git a/mm/memory.c b/mm/memory.c > index ba1d08a908a4..c893f5ffc5a8 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -1451,9 +1451,8 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, > if (pte_young(ptent) && > likely(!(vma->vm_flags & VM_SEQ_READ))) > mark_page_accessed(page); > + } > + page_zap_pte_rmap(page); > munlock_vma_page(page, vma, false); > rss[mm_counter(page)]--; > if (unlikely(page_mapcount(page) < 0)) > diff --git a/mm/rmap.c b/mm/rmap.c > index 69de6c833d5c..28b51a31ebb0 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -1413,47 +1413,26 @@ static void page_remove_anon_compound_rmap(struct page *page) > } > > /** > + * page_zap_pte_rmap - take down a pte mapping from a page > * @page: page to remove mapping from > * > + * This is the simplified form of page_remove_rmap(), that only > + * deals with last-level pages, so 'compound' is always false, > + * and the caller does 'munlock_vma_page(page, vma, compound)' > + * separately. > * > + * This allows for a much simpler calling convention and code. > * > * The caller holds the pte lock. > */ > +void page_zap_pte_rmap(struct page *page) > { > if (!atomic_add_negative(-1, &page->_mapcount)) > return; > > lock_page_memcg(page); > + __dec_lruvec_page_state(page, > + PageAnon(page) ? NR_ANON_MAPPED : NR_FILE_MAPPED); > unlock_page_memcg(page); > } So we *could* use atomic_add_return() and include the print_bad_pte() thing in this function -- however that turns the whole thing into a mess again :/