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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8AABC433EF for ; Thu, 11 Nov 2021 13:06:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4D6746120D for ; Thu, 11 Nov 2021 13:06:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4D6746120D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 7BE3C6B0071; Thu, 11 Nov 2021 08:06:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 76EA46B007B; Thu, 11 Nov 2021 08:06:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60EBD6B0081; Thu, 11 Nov 2021 08:06:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id 4D5256B0071 for ; Thu, 11 Nov 2021 08:06:58 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 06FDF82913D0 for ; Thu, 11 Nov 2021 13:06:58 +0000 (UTC) X-FDA: 78796674474.26.401D521 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by imf25.hostedemail.com (Postfix) with ESMTP id D3B03B0001B3 for ; Thu, 11 Nov 2021 13:06:42 +0000 (UTC) Received: by mail-pg1-f175.google.com with SMTP id g28so5113501pgg.3 for ; Thu, 11 Nov 2021 05:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:to:cc:references :from:in-reply-to:content-transfer-encoding; bh=bps4ioSjssDqexG7TCttpX6rWJKGqfhYrDDqLvwy90M=; b=TI+5R/rLqjNZN86oVUGfTx/pCWAFM/BoHTQEt4z5bzQdTqWJM7q1nsPjpdvvnoajFq 1kAOPpuH3oS8/kLCZox//UbMPT42abP70DWyUIzCp6ARREB1TDcA2k15YhtqC34cBt0c h0YkAhBHCwExL5BVHAKkE/hUIRI+qo3rhKRjyXbBkYkwKU3hovOBBb/hyv/fcv/zg08N Ym2RTO8vPeTzXQyuHhoZyM5rCWGw8UI8pK96Jdcnb86RHOBHZxrvqK5V+FcygAAzDBa+ WZFHnSjYSx25UoZa5x2otp6pDbBhzidm/vFNhx/b8qQauht/Bn00wx0ocd2hlbH4VaQq Toyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :to:cc:references:from:in-reply-to:content-transfer-encoding; bh=bps4ioSjssDqexG7TCttpX6rWJKGqfhYrDDqLvwy90M=; b=TWX9j+M8S6hyA+Lpfm0UY76N6YKGpFosfiA8OUDy/lulK0HpHoqPN9JYZcs06p0pNS DVY0YxUh/sZg8ejNjllxTsZKa5SANqUkPwA5F+aiQlJZ7KsOKASc0hru0tQDwy2D/x89 zIjyPhZ8Spigs70EAZReRNXSTRsov9VsWqKWQJp+ZJNs+wMEkrCA3NRuqsKfR+li/NZf 170vQ2Z2JqaU2sEzDjXrOa6TQ6gpJ6OKrtBTdA30owLXJHKnmCSA1PTy3gP+994KKzBO CN9qOcNC/KExCZTtkbsQKPtiYYqIKvnwhQY4eu143YhICS7tqofRsZvQTwbIa+nc1+W0 9q/A== X-Gm-Message-State: AOAM533wavb7LKHw7nQyCS3KgSdTh2hzdHMx8nIKXPnEU0QZz4j55hQ0 lI/f+4XL4uDuLnITywFOGiEkUGZAOVlY5w== X-Google-Smtp-Source: ABdhPJxkJ/QhSqPEiOZwSY+bDiTl+pmqtTYDvWS9ljzUpvQfkCP/5UixXtVDUn0gjMXzYyF+SWYcFg== X-Received: by 2002:a63:7c0d:: with SMTP id x13mr4419686pgc.410.1636635709355; Thu, 11 Nov 2021 05:01:49 -0800 (PST) Received: from [10.254.173.217] ([139.177.225.248]) by smtp.gmail.com with ESMTPSA id y18sm3908650pfa.142.2021.11.11.05.01.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Nov 2021 05:01:48 -0800 (PST) Message-ID: Date: Thu, 11 Nov 2021 21:01:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH v3 00/15] Free user PTE page table pages To: David Hildenbrand , Jason Gunthorpe Cc: akpm@linux-foundation.org, tglx@linutronix.de, kirill.shutemov@linux.intel.com, mika.penttila@nextfour.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, songmuchun@bytedance.com, zhouchengming@bytedance.com References: <20211110105428.32458-1-zhengqi.arch@bytedance.com> <20211110125601.GQ1740502@nvidia.com> <8d0bc258-58ba-52c5-2e0d-a588489f2572@redhat.com> <20211110143859.GS1740502@nvidia.com> <6ac9cc0d-7dea-0e19-51b3-625ec6561ac7@redhat.com> <20211110163925.GX1740502@nvidia.com> <7c97d86f-57f4-f764-3e92-1660690a0f24@redhat.com> <60515562-5f93-11cd-6c6a-c7cc92ff3bf8@bytedance.com> <9ee06b52-4844-7996-fa34-34fc7d4fdc10@bytedance.com> <27d73395-70b4-fe4a-4c8d-415b43ff9c1f@redhat.com> <2e19ad1b-15f3-7508-c5d5-6c31765f26d3@bytedance.com> <1489f02f-d024-b9ec-2ab6-e6efc8a022f1@redhat.com> <791ddf94-5ad1-b431-85a1-db9a07579057@bytedance.com> <2ffa76f5-ca39-2044-61fa-5398faf16a6c@redhat.com> From: Qi Zheng In-Reply-To: <2ffa76f5-ca39-2044-61fa-5398faf16a6c@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: D3B03B0001B3 X-Stat-Signature: fuxe9qrrchp745457runnb8xayj71i8y Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="TI+5R/rL"; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf25.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.175 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com X-HE-Tag: 1636636002-577336 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 11/11/21 8:51 PM, David Hildenbrand wrote: >>>> >>>> In the performance test shown on the cover, we repeatedly performed >>>> touch and madvise(MADV_DONTNEED) actions, which simulated the case >>>> you said above. >>>> >>>> We did find a small amount of performance regression, but I think it is >>>> acceptable, and no new perf hotspots have been added. >>> >>> That test always accesses 2MiB and does it from a single thread. Things >>> might (IMHO will) look different when only accessing individual pages >>> and doing the access from one/multiple separate threads (that's what >> >> No, it includes multi-threading: >> > > Oh sorry, I totally skipped [2]. > >> while (1) { >> char *c; >> char *start = mmap_area[cpu]; >> char *end = mmap_area[cpu] + FAULT_LENGTH; >> pthread_barrier_wait(&barrier); >> //printf("fault into %p-%p\n",start, end); >> >> for (c = start; c < end; c += PAGE_SIZE) >> *c = 0; >> >> pthread_barrier_wait(&barrier); >> for (i = 0; cpu==0 && i < num; i++) >> madvise(mmap_area[i], FAULT_LENGTH, MADV_DONTNEED); >> pthread_barrier_wait(&barrier); >> } >> >> Thread on cpu0 will use madvise(MADV_DONTNEED) to release the physical >> memory of threads on other cpu. >> > > I'll have a more detailed look at the benchmark. On a quick glimpse, Thank you for your time :) > looks like the threads are also accessing a full 2MiB range, one page at > a time, and one thread is zapping the whole 2MiB range. A single CPU > only accesses memory within one 2MiB range IIRC. > > Having multiple threads just access individual pages within a single 2 > MiB region, and having one thread zap that memory (e.g., simulate > swapout) could be another benchmark. LGTM, I will simulate more scenarios for testing. > > We have to make sure to run with THP disabled (e.g., using > madvise(MADV_NOHUGEPAGE) on the complete mapping in the benchmark > eventually), because otherwise you might just be populating+zapping THPs > if they would otherwise be allowed in the environment. Yes, I turned off THP during testing: root@~$ cat /sys/kernel/mm/transparent_hugepage/enabled always madvise [never] > -- Thanks, Qi