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 87939C00140 for ; Tue, 2 Aug 2022 20:59:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D07E48E0002; Tue, 2 Aug 2022 16:59:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB7268E0001; Tue, 2 Aug 2022 16:59:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B57F88E0002; Tue, 2 Aug 2022 16:59:47 -0400 (EDT) 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 A77C98E0001 for ; Tue, 2 Aug 2022 16:59:47 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 73BFF140FD8 for ; Tue, 2 Aug 2022 20:59:47 +0000 (UTC) X-FDA: 79755869214.12.46FF055 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id A755AA000E for ; Tue, 2 Aug 2022 20:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659473986; 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=FlYyxUq4TBUO2ujDZlR7hAoRGaLEjsFsfXjHZjjIh3c=; b=e+gmjAiQ1PBWMmQ0cRfcxPJ0WNdzfO7ntdDVL1vH5zwFGSxIy7M81LGOpoQm7SgXxHQ/hL 9k/N0TmopqIHxHJLxERRWeVqpUKE6niXWaf4Lv/WM3YLBqvx+hxkWyr5TbGvYuBICTZbP4 ffQJKDXe5XAzC3oHdLYy8b7N4lMKa4M= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-75-FC00iYZoMcaWnoVNSLns0w-1; Tue, 02 Aug 2022 16:59:45 -0400 X-MC-Unique: FC00iYZoMcaWnoVNSLns0w-1 Received: by mail-wm1-f69.google.com with SMTP id q10-20020a1ce90a000000b003a4f6e08166so30082wmc.5 for ; Tue, 02 Aug 2022 13:59:44 -0700 (PDT) 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 :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=FlYyxUq4TBUO2ujDZlR7hAoRGaLEjsFsfXjHZjjIh3c=; b=MoynoxLgq6qA4qrhsZgE8G1KlAqfSwZ2gy7ty1LxiDdVhua9ClBLDj4g//buo2RUPj Gth6xcC0CDg2sSZndI1vPKqllTIc7L32N5TZTNbCN4uSoEdQNX1QpNzYEAhMVghIqQn0 tLBygeEksiaKJJ0Iz8hdpU55emhgHzY05hKw4+15OPS8Aa3s9UOUilK/5KtfemUV8VQj viZ218QBJE0c6fbJWjSuTyubcHxemDUjXNY+c+Ptqpps99+5maTs9Wl2Z6sGuE6yzS6x lpR/qo/BZhumQaKIGmMRUERLqSID/uwuFaEsZQMbtZRoWO+gVG3BAo3zhhVsPBJS6G51 s1xA== X-Gm-Message-State: ACgBeo3CtRNKMfa9EtraYxGFfrFalBsshzvNF84cT+vC6qOG6+92xDli N624nyiwLXUZe2Dz8YsaLig18bTt8SoC3ao4sSzl4MKTOV0IiwF7Nf3PgE4RV/CCpkb/qKz/avI 5q4tT6dol2t4= X-Received: by 2002:a05:6000:18a2:b0:21d:bc7c:1c83 with SMTP id b2-20020a05600018a200b0021dbc7c1c83mr13941203wri.420.1659473983937; Tue, 02 Aug 2022 13:59:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR6NvLMSUgfym6qig+NNK7JeAaiHpc6m+XOmwm4mwjmY8k0qE+y0bjE9xFGipim2nNc0Tbk69g== X-Received: by 2002:a05:6000:18a2:b0:21d:bc7c:1c83 with SMTP id b2-20020a05600018a200b0021dbc7c1c83mr13941195wri.420.1659473983636; Tue, 02 Aug 2022 13:59:43 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:3800:8435:659e:f80:9b3d? (p200300cbc70738008435659e0f809b3d.dip0.t-ipconnect.de. [2003:cb:c707:3800:8435:659e:f80:9b3d]) by smtp.gmail.com with ESMTPSA id k41-20020a05600c1ca900b003a2e5f536b3sm26163056wms.24.2022.08.02.13.59.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Aug 2022 13:59:43 -0700 (PDT) Message-ID: <4f876ff0-c6d2-2ebb-5917-dc1ff98fa8b0@redhat.com> Date: Tue, 2 Aug 2022 22:59:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 To: Peter Xu Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Andrea Arcangeli , Andrew Morton , "Kirill A . Shutemov" , Nadav Amit , Hugh Dickins , Vlastimil Babka References: <20220729014041.21292-1-peterx@redhat.com> <49434bea-3862-1052-2993-8ccad985708b@redhat.com> <24ffea6e-ca66-2b94-c682-48a42a655fd1@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH RFC 0/4] mm: Remember young bit for migration entries In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659473987; 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=FlYyxUq4TBUO2ujDZlR7hAoRGaLEjsFsfXjHZjjIh3c=; b=cOivdsXfY4kW6EYPkV+1xede6rC5dUOjHHsc4ORUlvsL5MSUYrT8mdQf7kSJEbF8a+1crJ V1wOxFfr2MnYLxVqaAn5bSodr1h71KLrDv6kT6omQw6aAqPZl5BDC4Kbbq9/4iWCqxG1JI 4zID+CFPSAonpsMxawdpkpw+davNlW8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=e+gmjAiQ; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.129.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=1659473987; a=rsa-sha256; cv=none; b=jrclRMuY8mDan3nCXlCtUOTCZHBM8AaANqYQ8ZiYbgJWqrON0UG/mzadmn+wD/16L5Beoq c8YQuE1XBQSCiAc9mBjGbt3iIzbDJA2LXPbqaXBg0SkFx9vAHlpf1AStk6f9zzFmrS3LOg qEYxk2mrhBLqNTJwCJBwTloiozJi2A8= X-Stat-Signature: kx5nmap1zm6gf81zcrbyajdxpsd1jswy X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A755AA000E Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=e+gmjAiQ; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1659473986-586264 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 02.08.22 22:35, Peter Xu wrote: > On Tue, Aug 02, 2022 at 10:23:49PM +0200, David Hildenbrand wrote: >>> I don't think we only care about x86_64? Should other archs have the same >>> issue as long as there's the hardware young bit? >>> >>> Even without it, it'll affect page reclaim logic too, and that's also not >>> x86 only. >> >> Okay, reading the cover letter and looking at the code my understanding >> was that x86-64 is the real focus. >> >>>> >>>>> >>>>> Besides I actually have a question on the anon exclusive bit in the swap >>>>> pte: since we have that anyway, why we need a specific migration type for >>>>> anon exclusive pages? Can it be simply read migration entries with anon >>>>> exclusive bit set? >>>> >>>> Not before all arch support pte_swp_mkexclusive/pte_swp_exclusive/. >>>> >>>> As pte_swp_mkexclusive/pte_swp_exclusive/ only applies to actual swap >>>> PTEs, you could even reuse that bit for migration entries and get at >>>> alteast the most relevant 64bit architectures supported easily. >>> >>> Yes, but I think having two mechanisms for the single problem can confuse >>> people. >>> >> >> It would be one bit with two different meanings depending on the swp type. >> >>> IIUC the swap bit is already defined in major archs anyway, and since anon >>> exclusive bit is best-effort (or am I wrong?..), I won't worry too much on >> >> It kind-of is best effort, but the goal is to have all archs support it. >> >> ... just like the young bit here? > > Exactly, so I'm also wondering whether we can move the swp pte anon > exclusive bit into swp entry. It just sounds weird to have them defined in > two ways. I'd argue it's just the swp vs. nonswp difference that are in fact two different concepts (device+offset vs. type+pte). And some dirty details how swp entries are actually used. With swp entries you have to be very careful, for example, take a look at radix_to_swp_entry() and swp_to_radix_entry(). That made me refrain from touching anything inside actual swp entries and instead store it in the pte. > >> >>> archs outside x86/arm/ppc/s390 on having anon exclusive bit lost during >>> migrations, because afaict the whole swap type of ANON_EXCLUSIVE_READ is >>> only servicing that very minority.. which seems to be a pity to waste the >> >> I have a big item on my todo list to support all, but I have different >> priorities right now. >> >> If there is no free bit, simply steal one from the offset ... which is >> the same thing your approach would do, just in a different way, no? >> >>> swp type on all archs even if the archs defined swp pte bits just for anon >>> exclusive. >> >> Why do we care? We walk about one type not one bit. > > The swap type address space is still limited, I'd say we should save when > possible. I believe people caring about swapping care about the limit of > swap devices too. If the offset can keep it, I think it's better than the Ehm, last time I did the math I came to the conclusion that nobody cares. Let me redo the math: MAX_SWAPFILES = 1<<5 - 1 - 1 - 4 - 3 - 1 = 22 Which is the worst case right now with all kinds of oddity compiled in (sorry CONFIG_DEVICE_PRIVATE). So far nobody complaint. > swap type. De-dup either the type or the swap pte bit would be nicer, imho. > If you manage bits in the pte manually, you might be able to get a better packing density, if bits are scattered around. Just take a look at the x86_64 location of _PAGE_SWP_EXCLUSIVE. What I'm rooting for is something like #define pte_nonswp_mkyoung pte_swp_mkexclusive Eventually with some VM_BUG_ONs to make sure people call it on the right swp ptes. If we ever want to get rid of SWP_MIGRATION_READ_EXCLUSIVE (so people can have 23 swap devices), and eventually have separate bits for both. For now it's not necessary. -- Thanks, David / dhildenb