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 1BE69C25B74 for ; Fri, 24 May 2024 23:55:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F56F6B0085; Fri, 24 May 2024 19:55:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 47E896B0088; Fri, 24 May 2024 19:55:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F8736B0089; Fri, 24 May 2024 19:55:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0EC2B6B0085 for ; Fri, 24 May 2024 19:55:55 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7DDB840243 for ; Fri, 24 May 2024 23:55:54 +0000 (UTC) X-FDA: 82154949828.23.A744694 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id A39252000D for ; Fri, 24 May 2024 23:55:52 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=COUqFr0Q; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@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=1716594952; 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=SJYbdmLwWG2mW4WyVnckXu838LCXN0AwY1i3rf08V9s=; b=L4GZSb/dRxQLKGx9NC+xlyMv9Jva7Vcr9XILsFxhWZcnCGrbpq4LU0luIN8QBWTYiNdPaV ka/P/u5zMsYfsQPN39WfFMMyKHCMeY+nZj4O+blpaS64PIzzyWEpr+le1ao44T7IXndu4n OQvBi9Mw4tUnNRuyY/a7xu7zxf7tYTs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716594952; a=rsa-sha256; cv=none; b=1lbkjPZgXw3A4uaUeOeLlytYAhr+R9xxTnZQA2Le6KuP6Gcc9plzxl9+alShNCPMRVZ8fl mo9suI41vQzel0HeVxScOKU7Y3fGO61s3kMzxRAdFxVw28fudIylClE9I5HvNw+JGwiVeM PRrYS8VxE8D0ejfKNDSsEbrbGGAV/9A= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=COUqFr0Q; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716594951; 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: in-reply-to:in-reply-to:references:references; bh=SJYbdmLwWG2mW4WyVnckXu838LCXN0AwY1i3rf08V9s=; b=COUqFr0QdSBwHl/z83RolW3Av+d6my9qE4aTseu4XCCKC0dWsTDUyc7HmDPB2rGey2yoH5 /mDrtGvK2PCN1lBvIgkron/1QpikEHPE7dbXtl1CMZZCqj2/hhCnOqSW/JrJD528c+fGpL KF0j5+zOUbmCkFYvnfJMMysRVKw8Fcs= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-349-WtLD2BeROJuybHF38ITYFg-1; Fri, 24 May 2024 19:55:50 -0400 X-MC-Unique: WtLD2BeROJuybHF38ITYFg-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6ab8ec745e6so5207216d6.2 for ; Fri, 24 May 2024 16:55:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716594950; x=1717199750; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SJYbdmLwWG2mW4WyVnckXu838LCXN0AwY1i3rf08V9s=; b=LdgWKPMIMkbooxB+uy6okJB1HWLQyA3HkNGbSRHrHEju2S01ghzm229nsEL2IUo41s IpmqEAIpeT3UPb/ypjdTzCrk7PQgrl/38uOVek25rYZlCqnkF7zbbLqfXGWWijUeogAc 6CjsATEEEq6QknTDwoRsC7JLl5TEEj9KmTcoCPYkMIroeTo0SiRLP5/MUvRjf6DHd3GI r6VqQfNCWMoZgpt6GLvnGASREJdf32ZHinrDNyCUZAnRTXBi5RaL2xEOTu7Ntqx+lGXR wOiu0Ze7gy61oW2Dz8f3UIZEvDFRacvnK6bRie+k9QukdkY7rqbqHt1fDvUfqZ82o1jA hNDw== X-Gm-Message-State: AOJu0YwOQBXMQfLHJn/6NPkEjE3sfd2XArh7eIHxLHDr8j+zZ0Lxo/4y 6vLcdYXheg6LsTCOBP5Y1RIDPBOKi54VuCEJ8N/E//gwJeDnqz4FQ6DGgbDDEshca2bB0WsuNh0 cRFF5qtUh2tioIBkdsV1zSBSQ4hW3hl6/p6FQGrSrmZBAFHBU X-Received: by 2002:a05:6214:c29:b0:6ab:8df8:b90e with SMTP id 6a1803df08f44-6aba272986amr37784286d6.0.1716594949894; Fri, 24 May 2024 16:55:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnwu5aSfI6m6qOi3M0v/dTrcCZEiAFepKlQxx7tBpg+46HqilMzOzDa69f7l/GkD1vqTrGcg== X-Received: by 2002:a05:6214:c29:b0:6ab:8df8:b90e with SMTP id 6a1803df08f44-6aba272986amr37783976d6.0.1716594949087; Fri, 24 May 2024 16:55:49 -0700 (PDT) Received: from x1n (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ac162f2f35sm11667776d6.77.2024.05.24.16.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 16:55:48 -0700 (PDT) Date: Fri, 24 May 2024 19:55:46 -0400 From: Peter Xu To: Dave Hansen Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Jason Gunthorpe , Andrew Morton , Al Viro , Dave Hansen , Andy Lutomirski , Matthew Wilcox , Dan Williams , "Kirill A . Shutemov" , Mike Rapoport , Ingo Molnar , Michal Hocko , Alex Williamson , Peter Zijlstra , Suren Baghdasaryan , Borislav Petkov , x86@kernel.org Subject: Re: [PATCH RFC 2/2] mm/x86/pat: Do proper PAT bit shift for large mappings Message-ID: References: <20240523223745.395337-1-peterx@redhat.com> <20240523223745.395337-3-peterx@redhat.com> <7b6b6430-0237-4512-b99b-9eb815b3dc68@intel.com> MIME-Version: 1.0 In-Reply-To: <7b6b6430-0237-4512-b99b-9eb815b3dc68@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A39252000D X-Rspam-User: X-Stat-Signature: 4pfyjku7qbgij1cnt7huz4ibxfxre9bk X-HE-Tag: 1716594952-101118 X-HE-Meta: U2FsdGVkX19kge+Iu5ysqgtJsEtVeMjs5OkdXCODlswui3toAu1ZotAVU5nYvQv2/bFQb4S0fBZ0919Q21beXBIJQerV+sWmBI0S7yI3N0bxbbNiu22pi/O1RrbnpP9rI56IKlKyLxY4TYsR0CRfUiUY47N1EmFG06qPPmZepV1L3YVS2AykV0Z6MWDKv79/NCjwfDmB0TqEEP61w5nRpRu1QF5bmwcsPUVfpInlmDYGph4vn3ORzu12rdNFPPB2LZ6nRjO+u7aI+V8ODpyzkXCMR1kUG0+GinmcSV2d74D2ceG2E5vRYUUsNC29Cm1VCjEArzMb9PbUJAmiLCn1PffbYfkd3O8no0GIVTBgp52xTuK+CK0ZCXgI1hMe6AzjOeY2TJZd6REL3Ixn0qDX5tOfby5mLrotSPVU9Pm48PeHtbjmudaF1I/N6jVWcyKfn946rbgrYcmOyMMPXa6KQ2r5VW9agGduEuyLH/Qwb7OfsdqBkoDLgyYqxMgzlhyv1PeiEsIEL237WXbIs5dqmQ+4WwMOWZ0lt8kOLnk6dI5Q6i2aGYdKRnhY76QpmPbBrTHLYxAnOJmMAhE4LdUl5AtKM2fmSnBT7GYV9wi/nc2yk13bxeTiTtKcb/PCoga2+Hlb55dshlA+DNVEIYUMFny0MQ+uVIj283i7KwJO2WyKPani0FAVv7IcmM9oJlPpWcvZt7DYVbF0pVsePXwwEVMJDojNlj5QSBLAbwhiYEhgCUC9ATEO4+Fp/YsPcNDQSdQuU3wZDzqtMvA4NcwjDneQOKNnL0qNPX1B/gWwlSMEeXx6gVMvOgGGI2NkCjt30U6mms+VztmLheXjc8a1HlLm9auCPtieW4j5u/aCyaTFJq8+WjpkBETfAJwWdcUivRI//wf8J/jWMPvTOsqltVQ1dV+BAvErapf3SvvMK/qZ1VhvqDiQxV2WNWumP5j777quvALXF7ayE8FFlJE C7RPziZj es+J6E1SVoYhwC9rcL6k80yorlZSNpJntXJjZ4B6z+6BRNvFWi1ZlW5/T13dfnFtL1UYiS+MabizhFom44Z/fuPcymw== 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: List-Subscribe: List-Unsubscribe: On Thu, May 23, 2024 at 08:30:19PM -0700, Dave Hansen wrote: > On 5/23/24 16:07, Peter Xu wrote: > > Probably not.. I think I can define a pgprot_to_large() globally, pointing > > that to pgprot_4k_2_large() on x86 and make the fallback to be noop. And > > if there's a new version I'll guarantee to run over my cross compilers. > > I guess that would be functional, but it would be a bit mean to > everybody else. > > > Any comments on the idea itself? Do we have a problem, or maybe I > > overlooked something? > > I think it's probably unnecessary to inflict this particular x86-ism on > generic code. The arch-generic 'prot' should have PAT at its 4k > (_PAGE_BIT_PAT) position and then p*d_mkhuge() can shift it into the > _PAGE_BIT_PAT_LARGE spot. Right that's another option indeed. It's just that I found it might in many cases be better when we have the API separately properly and making the pairs matching each other. For example, it could be clearer if pxx_mkhuge() does exactly what pxx_leaf() would check against. PS: I hoped it's called pxx_huge() already to make the name paired with each other; afaict we called it pxx_leaf() only because pxx_huge() used to be "abused" by hugetlbfs before.. now it's gone. The other thing is we mostly only need these knobs for special maps like pfnmaps, am I right? OTOH we use WB for RAMs, and maybe we don't want to bother any PAT stuff when the kernel is installing a THP anonymous? IMHO having pgprot_to_large() is fine even if only x86 has it; it's really like pfn tracking itself which is noop for !x86. but I'll follow your advise if you still insist; I don't really have a strong opinion. But if so I'd also like to mention a 3rd option, which is to have pxx_mkhuge_prot(), fallback to pxx_mkhuge() for !x86. That'll make pxx_huge() untainted for x86. I'm not sure whether that would ease the same concern, though. In all cases, thanks for confirming this issue, I appreciate that. Let me know if you have any comment on patch 1 too; that one isn't a problem so far iiuc, but it can be soon. Thanks, -- Peter Xu