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 X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2C97C47087 for ; Fri, 28 May 2021 10:21:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5D581613DA for ; Fri, 28 May 2021 10:21:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D581613DA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B84D56B006C; Fri, 28 May 2021 06:21:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE67E6B006E; Fri, 28 May 2021 06:21:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EAC86B0070; Fri, 28 May 2021 06:21:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id 57C036B006C for ; Fri, 28 May 2021 06:21:25 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E5049B9FC for ; Fri, 28 May 2021 10:21:24 +0000 (UTC) X-FDA: 78190247688.05.17B7DB0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id CD33E503BD26 for ; Fri, 28 May 2021 10:21:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622197284; 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=oRtLgByD3ejpQsxciFOP3GYk1lL3gyURmaecEKKGJtM=; b=XR8NZQvB8zg3Gw8qBR3dg5TJ1aBhwu91cYIcQ8oWJWjveFyEQZEu/lbhL2fSqNd4A6eSAw fqBsuYSNsFxkJVKmEzkuKVbM1a9zemhtOYV+4a12KsQubZ5q1DwJJu3N0ta1ZWlwRmgRbR IcDHksAHcyqdYXEi990kOdXOyPE3doQ= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-572-pfmHXKOGMZKCoPGKqK-XMQ-1; Fri, 28 May 2021 06:21:22 -0400 X-MC-Unique: pfmHXKOGMZKCoPGKqK-XMQ-1 Received: by mail-wm1-f69.google.com with SMTP id f141-20020a1c1f930000b029017ce5240ed6so1192689wmf.5 for ; Fri, 28 May 2021 03:21:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=oRtLgByD3ejpQsxciFOP3GYk1lL3gyURmaecEKKGJtM=; b=VJnSC8M2ao4mLyD+vH4MZslPV8VH1mLUYtJiF21fONNmOySFWf/tsfBQGboWb6Kn81 TmbyKnshrXTYWAhLLuPOtQOYCvRlO2M4sga1olJS4g98nB9cRnphGpBmq/PsDrDiuJXm JsR6pHMBaV+pRh21NRbHNsGipfZ8DombsLE2ZwkkgbQefSji/ybfUcX60G/nhybX4iKC EKAqPlVw4vV5JXR2JBBLdsRe8m2xw+VjsF9kCcKL5rw/S2JjkYBxRcd26IDN3lS9mR0b xSCxXtwBlAgOBnbmOMo8P8VjVsRWFU4qUHKee+LZBRXSuFtxa0GMw3LudJOzJPPoVaba eOxQ== X-Gm-Message-State: AOAM531nLD0Sn8gViYy0HY3U50GPvAtlll0XCn6IU1Dd8ycymga3Uci3 j/pxOcVjFGFJ4xC/XnMyR36Mf/Jzov1xoZcEwOc910/Vb5k3tgEyEt35F4pSMaWc47+fCUYegGe 33a3FlvbDSkw= X-Received: by 2002:a5d:534f:: with SMTP id t15mr7687187wrv.206.1622197281555; Fri, 28 May 2021 03:21:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2/Z2o0e07haEOrsooEHs87bLVJKGph3BWfu7UwTODy5CsgBcWMazSCki58gq4VcnKsmzLug== X-Received: by 2002:a5d:534f:: with SMTP id t15mr7687160wrv.206.1622197281325; Fri, 28 May 2021 03:21:21 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6870.dip0.t-ipconnect.de. [91.12.104.112]) by smtp.gmail.com with ESMTPSA id m9sm6499072wrq.78.2021.05.28.03.21.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 May 2021 03:21:21 -0700 (PDT) To: Mel Gorman Cc: Dave Hansen , Andrew Morton , Hillf Danton , Dave Hansen , Vlastimil Babka , Michal Hocko , LKML , Linux-MM , "Tang, Feng" References: <20210525080119.5455-1-mgorman@techsingularity.net> <7177f59b-dc05-daff-7dc6-5815b539a790@intel.com> <20210528085545.GJ30378@techsingularity.net> <54ff0363-2f39-71d1-e26c-962c3fddedae@redhat.com> <20210528094949.GL30378@techsingularity.net> <6c189def-11cc-80db-0fde-56aa506cfdea@redhat.com> <20210528100918.GM30378@techsingularity.net> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH 0/6 v2] Calculate pcp->high based on zone sizes and active CPUs Message-ID: <8d6dfad6-ae0b-fd47-1d83-23baf82921b4@redhat.com> Date: Fri, 28 May 2021 12:21:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210528100918.GM30378@techsingularity.net> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Language: en-US X-Rspamd-Queue-Id: CD33E503BD26 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XR8NZQvB; spf=none (imf01.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam04 X-Stat-Signature: o1x1dc8s6fwixo4xnk145n84ifwhro5x X-HE-Tag: 1622197275-221074 Content-Transfer-Encoding: quoted-printable 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 28.05.21 12:09, Mel Gorman wrote: > On Fri, May 28, 2021 at 11:52:53AM +0200, David Hildenbrand wrote: >>>> "Disable pcplists so that page isolation cannot race with freeing >>>> in a way that pages from isolated pageblock are left on pcplists.= " >>>> >>>> Guess we'd then want to move the draining before start_isolate_page_= range() >>>> in alloc_contig_range(). >>>> >>> >>> Or instead of draining, validate the PFN range in alloc_contig_range >>> is within the same zone and if so, call zone_pcp_disable() before >>> start_isolate_page_range and enable after __alloc_contig_migrate_rang= e. >>> >> >> We require the caller to only pass a range within a single zone, so th= at >> should be fine. >> >> The only ugly thing about zone_pcp_disable() is >> mutex_lock(&pcp_batch_high_lock) which would serialize all >> alloc_contig_range() and even with offline_pages(). >> >=20 > True so it would have to be accessed if that is bad or not. If racing > against offline_pages, memory is potentially being offlined in the > target zone which may cause allocation failure. If racing with other > alloc_contig_range calls, the two callers are potentially racing to > isolate and allocate the same range. The arguement could be made that > alloc_contig_ranges should be serialised within one zone to improve the > allocation success rate at the potential cost of allocation latency. We have 3 main users of alloc_contig_range(): 1. CMA CMA synchronizes allocation within a CMA area via the allocation bitmap.=20 So parallel CMA is perfectly possible and avoids races by design. 2. alloc_contig_pages() / Gigantic pages Gigantic page allocation could race with virtio-mem. CMA does not apply.=20 Possible but unlikely to matter in practice. virtio-mem will retry later=20 again. 3. virito-mem A virtio-mem device only operates on its assigned memory region, so we=20 cannot have alloc_contig_range() from different devices racing, even=20 when within a single zone. It could only race with gigantic pages as CMA=20 does not apply. So serializing would mostly harm parallel CMA (possible and likely) and=20 parallel virtio-mem operation (e.g., unplug memory of two virtio-mem=20 devices -- unlikely but possible). Memory offlining racing with CMA is not an issue (impossible).=20 virtio-mem synchronizes with memory offlining via memory notifiers,=20 there is only a tiny little race window that usually doesn't matter as=20 virtio-mem is expected to usually triggers offlining itself, and not=20 user space rancomly. Memory offlining can race with dynamic gigantic=20 page allocation, wich is highly unreliable already. I wonder if we could optimize locking in zone_pcp_disable() instead. --=20 Thanks, David / dhildenb