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 81295C678D4 for ; Thu, 2 Mar 2023 10:10:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B0556B0074; Thu, 2 Mar 2023 05:10:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 061166B0075; Thu, 2 Mar 2023 05:10:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6AA26B0078; Thu, 2 Mar 2023 05:10:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D77A96B0074 for ; Thu, 2 Mar 2023 05:10:13 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A6DC9120900 for ; Thu, 2 Mar 2023 10:10:13 +0000 (UTC) X-FDA: 80523537906.08.BA41D59 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 7924614000B for ; Thu, 2 Mar 2023 10:10:11 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JzLGQbE5; spf=pass (imf23.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677751811; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LUPUq9rwM+2uCcwp+cjvg22RkhBv6eu14BsYsubV2S4=; b=uGeF8+5ovXbFeSIA+gFch8lLUNUD2u/fTZK5fGxCigZ6UoSKzQ10CRAMsdZY5O1ny6VdOZ X2mua+pZLtoMMf4tQuEVjy6QIth/g3Ov2sky/zEVRuuUWHRu1S50lKHaj6YmT8vwJdgkBE KSnC1/faHpi3cKjUBJ1IirRigsy2690= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JzLGQbE5; spf=pass (imf23.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677751811; a=rsa-sha256; cv=none; b=GbHS5iZj4BrmB+1wRTcVtnJcP3JT6jGM91wkdkasLc91xjc2XCfVXtZ++Ouujnsd08cS0o Ln5fB+0RwrzgpQ8JxbRjitoHOpBBpItJHv1ZpnqEkzDd/Pih6fghTLQx8IlY3DwcVWc+zA FovQt9JrUTc3EFmNeqZCStGTeyvABXc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677751810; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LUPUq9rwM+2uCcwp+cjvg22RkhBv6eu14BsYsubV2S4=; b=JzLGQbE5ek9BFwj2N0z/EjTJqDzTMTV2ZCLIOXYCLVvLgNbBUjYxhAXRCS+Exktn4uYsaW nIFjhzaHAcCTHRxFvTIRgdGk+roYakjkRhnh1vP5/mZSF5Neor2rI1e9gXN1NZi+/OAngN j2rrtmOt8+nebt8CT5isVS8IaFoFKXc= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-104-3LLRmvyaMNS_fhGPAbQmiQ-1; Thu, 02 Mar 2023 05:10:07 -0500 X-MC-Unique: 3LLRmvyaMNS_fhGPAbQmiQ-1 Received: by mail-wm1-f72.google.com with SMTP id n27-20020a05600c3b9b00b003e9ca0f4677so857032wms.8 for ; Thu, 02 Mar 2023 02:10:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LUPUq9rwM+2uCcwp+cjvg22RkhBv6eu14BsYsubV2S4=; b=SHdVvrsMzbTkDtlDH0XtS7JFyV/1DGgu6bYXO1oTpq7q0Zo2Udodv4KqbFo6yvT+Xn HKlBoWKAAoG38uf8RAyAa1t3sXtT4Zv8L0obGELwPydTg14M+Ro2IwJHwUXTnGlR6eXT khYjqSd5Pt4eODEf9vGeX0yyd6PZBqEE2Kwwlu6Yst5kNDRRT/aK0IyRcXgUaF+Vh1wZ CMg2HYCUzKAits4zd1FzSocZtI+e3opyiupxQyePTOmmg0TDjeaPiKJpM/8urJegDBvV XXYBs+IiAME2fiIxH3Wq09of/Xx/Hex6tUbm+83gY6wm+MZqNjDntbaz/NYy5zT21E5x J0fg== X-Gm-Message-State: AO0yUKWhqp5RIFOshNoElKC3+/ZpJEJqbcSfiin9kShDjimDNmXi9k10 6t1iLUEkq9Dp2QMLzrXFlNEiCJPbw1rCNmxVcYutHiX7MSly0E/xDgvwtlaf8CH52HdvbqsNZhz DzHLRe3HCr2M= X-Received: by 2002:a05:600c:4590:b0:3eb:3945:d3f1 with SMTP id r16-20020a05600c459000b003eb3945d3f1mr6873245wmo.5.1677751805515; Thu, 02 Mar 2023 02:10:05 -0800 (PST) X-Google-Smtp-Source: AK7set9K2AzGQBPeisGsiHzjscpGYd24l7mhU6n0z2IIo/uIK6J3kzQV4bxrLrhC3WeAmqQld33fvA== X-Received: by 2002:a05:600c:4590:b0:3eb:3945:d3f1 with SMTP id r16-20020a05600c459000b003eb3945d3f1mr6873222wmo.5.1677751805149; Thu, 02 Mar 2023 02:10:05 -0800 (PST) Received: from ?IPV6:2003:cb:c70e:4f00:87ba:e9e9:3821:677b? (p200300cbc70e4f0087bae9e93821677b.dip0.t-ipconnect.de. [2003:cb:c70e:4f00:87ba:e9e9:3821:677b]) by smtp.gmail.com with ESMTPSA id j8-20020a056000124800b002c71d206329sm14655629wrx.55.2023.03.02.02.10.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Mar 2023 02:10:04 -0800 (PST) Message-ID: <3329f63e-5671-1500-0730-cd46ba461d04@redhat.com> Date: Thu, 2 Mar 2023 11:10:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v2 01/11] mm/vmstat: remove remote node draining To: Marcelo Tosatti Cc: Christoph Lameter , Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mel Gorman , Vlastimil Babka References: <20230209150150.380060673@redhat.com> <20230209153204.656996515@redhat.com> <6b6cd2fe-2309-b471-8950-3c4334462e69@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 7924614000B X-Stat-Signature: ags91aqewf8oh37cc54grae8aog5k5jg X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1677751811-692705 X-HE-Meta: U2FsdGVkX19VgBvNxn5T6bNNcKaJ8ftgyId3J2nabs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PN6n5+QvmMtRTCKhamZLwlRHcqCItoE8jISC7wcFAFIGqsLrNAOWQvMjVf4NczIOzn2l4tk11Du9Y+Vuh7RVO9EsF0QZhajqjPmDCy3aurdfdB1uPuGYi2VUNYYfdVUclzsy39R2jR/S/PQa3gC14fz/Fo/C+rdDXq/D2pfVZE7GBLyb3NjK3qE3yKnhYDKlGkll1A9bh5RHT62VpRMT/K00CEHyp8BYyz83dosPvSyjfkp1m7uj+WwvR4vaHX5yUU9ovaFkNaiahIunjmp/xAm8OkrHc6Icv9jPTvvamGOTc= 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: [...] > >> (2) drain_zone_pages() documents that we're draining the PCP >> (bulk-freeing them) of the current CPU on remote nodes. That bulk- >> freeing will properly adjust free memory counters. What exactly is >> the impact when no longer doing that? Won't the "snapshot" of some >> counters eventually be wrong? Do we care? > > Don't see why the snapshot of counters will be wrong. > > Instead of freeing pages on pcp list of remote nodes after they are > considered idle ("3 seconds idle till flush"), what will happen is that > drain_all_pages() will free those pcps, for example after an allocation > fails on direct reclaim: > > page = get_page_from_freelist(gfp_mask, order, alloc_flags, ac); > > /* > * If an allocation failed after direct reclaim, it could be because > * pages are pinned on the per-cpu lists or in high alloc reserves. > * Shrink them and try again > */ > if (!page && !drained) { > unreserve_highatomic_pageblock(ac, false); > drain_all_pages(NULL); > drained = true; > goto retry; > } > > In both cases the pages are freed (and counters maintained) here: > > static inline void __free_one_page(struct page *page, > unsigned long pfn, > struct zone *zone, unsigned int order, > int migratetype, fpi_t fpi_flags) > { > struct capture_control *capc = task_capc(zone); > unsigned long buddy_pfn = 0; > unsigned long combined_pfn; > struct page *buddy; > bool to_tail; > > VM_BUG_ON(!zone_is_initialized(zone)); > VM_BUG_ON_PAGE(page->flags & PAGE_FLAGS_CHECK_AT_PREP, page); > > VM_BUG_ON(migratetype == -1); > if (likely(!is_migrate_isolate(migratetype))) > __mod_zone_freepage_state(zone, 1 << order, migratetype); > > VM_BUG_ON_PAGE(pfn & ((1 << order) - 1), page); > VM_BUG_ON_PAGE(bad_range(zone, page), page); > > while (order < MAX_ORDER - 1) { > if (compaction_capture(capc, page, order, migratetype)) { > __mod_zone_freepage_state(zone, -(1 << order), > migratetype); > return; > } > >> Describing the difference between instructed refresh of vmstat and "remotely >> drain per-cpu lists" in order to move free memory from the pcp to the buddy >> would be great. > > The difference is that now remote PCPs will be drained on demand, either via > kcompactd or direct reclaim (through drain_all_pages), when memory is > low. > > For example, with the following test: > > dd if=/dev/zero of=file bs=1M count=32000 on a tmpfs filesystem: > > kcompactd0-116 [005] ...1 228232.042873: drain_all_pages <-kcompactd_do_work > kcompactd0-116 [005] ...1 228232.042873: __drain_all_pages <-kcompactd_do_work > dd-479485 [003] ...1 228232.455130: __drain_all_pages <-__alloc_pages_slowpath.constprop.0 > dd-479485 [011] ...1 228232.721994: __drain_all_pages <-__alloc_pages_slowpath.constprop.0 > gnome-shell-3750 [015] ...1 228232.723729: __drain_all_pages <-__alloc_pages_slowpath.constprop.0 > > The commit message was indeed incorrect. Updated one: > > "mm/vmstat: remove remote node draining > > Draining of pages from the local pcp for a remote zone should not be > necessary, since once the system is low on memory (or compaction on a > zone is in effect), drain_all_pages should be called freeing any unused > pcps." > > Thanks! Thanks for the explanation, that makes sense to me. Feel free to add my Acked-by: David Hildenbrand ... hoping that some others (Mel, Vlastimil?) can have another look. -- Thanks, David / dhildenb