Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp209427rwb; Thu, 27 Jul 2023 11:28:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlGPUUUIvMHclu2hMFaGGWTeDlmi/WBUGO7bqrdbWhB4UDLt3It7eqRwwE9bkESPmdRyJ+Xm X-Received: by 2002:a05:6808:b3c:b0:3a4:f8e:d798 with SMTP id t28-20020a0568080b3c00b003a40f8ed798mr4010033oij.36.1690482531880; Thu, 27 Jul 2023 11:28:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690482531; cv=none; d=google.com; s=arc-20160816; b=pwnW1FqOFiHiL3DvcGLh+ILNtUGvGXXFosnkFGv8TJc7ALxwx7Oko60wdzQD/qpH5e FjdbxZFKSQiAkJjV1UsVOB/C5wJBgcGFwM54XI6GqnY7O+AA3K9GJkPy5jdxbNjKgXfQ B4AU0CeDbOrO7SiJUa6LYtY/saFEV/EqfviwUPC3m/jU39/pnKp/rqgGCn6E3g7rqxpn zXHu1AfzGhgzhcyjVCMnp6DfM7OK/fYQFVBAPjIDkzdBVUjbsVcDaX08YCwpz3nsmB35 W1Kdw0AO8FxDhHTk+FcRuyFTXCVNg2K+lWh8WtjiPg4YWUqH62vbxW1FHhKfjoUi4xKh NOjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :organization:from:content-language:references:cc:to:user-agent :mime-version:date:message-id:dkim-signature; bh=cwb5DpfJA543/ymBOV9D0j7LfkCqnFRKOW5fcvoaQRM=; fh=zMFvIk0YgVUDfTXvRfrpSWJvKzlr4xZWkau8ISv+PNs=; b=Y3T9zd+nCvrlHkp1T92+ozvfuSi1LCnQj/+S/nJU6YGmkmO4YQMNq57SgcRcEmaRxd aOVry8eW6Zpt3FA6S8GSH93CQuOkRtGFLtrLkTER0o5xLefFhSbCQTYbHoa8F/C/7cVm AXIoNBzassMXgBelGEe91wqTLfDgDPGvJfNYhmu2Xqh/IQPlweRnWgaumVNHZyei63Rn 6biUP7bOhQE5jffxP2ui8xg4Rr7xYGPwpIT3KftO1+xfpx/Pt+IN7iy/HSK0ApLV7A3x jKIglgnmVFDZ7KZsKVhw9pOpBmFk93LuyVBHlE6Vz4v0p6ETEBhz9iyw7Yw99q06Fh4/ AX2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="UH/wvXz8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i25-20020a635859000000b005633492e104si1611939pgm.497.2023.07.27.11.28.39; Thu, 27 Jul 2023 11:28:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="UH/wvXz8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229940AbjG0R2b (ORCPT + 99 others); Thu, 27 Jul 2023 13:28:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231357AbjG0R16 (ORCPT ); Thu, 27 Jul 2023 13:27:58 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBC062D73 for ; Thu, 27 Jul 2023 10:27:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690478827; 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=cwb5DpfJA543/ymBOV9D0j7LfkCqnFRKOW5fcvoaQRM=; b=UH/wvXz8RbnYPSXQ9iyKvInOSlCPV6bwMvH6ZGICQNmHzniCvLddKDfP6Nh8VWTqI48irB z6StyfCLCMdrJ6BmhdXRlbNrgqW/ba6mfa9wurPdU7HaMbysMyW0c/Pte58/VeljfSkLqj d0KJWt/EtpQjcuihzd3tTmwRyxMB9j8= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-167-2zpwaD-oMby75C9JdMcPrQ-1; Thu, 27 Jul 2023 13:27:05 -0400 X-MC-Unique: 2zpwaD-oMby75C9JdMcPrQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fa96b67ac1so6556025e9.0 for ; Thu, 27 Jul 2023 10:27:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690478824; x=1691083624; h=content-transfer-encoding:in-reply-to:subject:organization:from :content-language:references:cc:to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cwb5DpfJA543/ymBOV9D0j7LfkCqnFRKOW5fcvoaQRM=; b=dGlyzsMzfU1klRBYDLaAQ8S6BTef1jAbMVbr2A4pkcmZhnK6MDBKExKADYYaas+gxi 2d+sDPw+CcTgXx+5Frj7nEhytjuTT+dwu7GuHLz7kA4wiCUE5NiYGVfV5CncCl7Cp8QI 85fTTsM7FX+XN/+JyjvTK+5FcfqGK1qd4C6c4H9c5KkxnEfss970+F/Q+Vk2MDY0MvBM /4LK+MOzYDTEAd8YH4vuWoOn21dNN1vWdLJEfwN0w+IQ1m5Fd8slmrnLmpzidUhhiJ7p NVGLI4HRgiD66Wsa4cNIKsCZL40182hKHzkH3zuqwlj3M2YwpM4pVckQNo/VR/NtOHIo jf7w== X-Gm-Message-State: ABy/qLYqtd4ZvOanxdz0FeAhfRik8rBQzLdpqlV3X+KzcABoOMVE8gua opelSAB6O+wmzuBeOS5t6lCtcUiliogSPvUBOpOi0B365ixj2bLrN1tqAl2hLWo6pZ69AQ/SpsU vqGrE7dIM/Om1iKB7q93e5kfI X-Received: by 2002:a05:600c:2110:b0:3fc:f9c:a3ed with SMTP id u16-20020a05600c211000b003fc0f9ca3edmr2408144wml.22.1690478824448; Thu, 27 Jul 2023 10:27:04 -0700 (PDT) X-Received: by 2002:a05:600c:2110:b0:3fc:f9c:a3ed with SMTP id u16-20020a05600c211000b003fc0f9ca3edmr2408128wml.22.1690478824018; Thu, 27 Jul 2023 10:27:04 -0700 (PDT) Received: from ?IPV6:2003:d8:2f43:4700:d2cd:2b81:d4e6:8b2a? (p200300d82f434700d2cd2b81d4e68b2a.dip0.t-ipconnect.de. [2003:d8:2f43:4700:d2cd:2b81:d4e6:8b2a]) by smtp.gmail.com with ESMTPSA id k15-20020a05600c0b4f00b003fbaade0735sm5239334wmr.19.2023.07.27.10.27.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Jul 2023 10:27:03 -0700 (PDT) Message-ID: <5a2c9ae4-50f5-3301-3b50-f57026e1f8e8@redhat.com> Date: Thu, 27 Jul 2023 19:27:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 To: Peter Xu Cc: liubo , akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, hughd@google.com, willy@infradead.org References: <20230726073409.631838-1-liubo254@huawei.com> Content-Language: en-US From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH] smaps: Fix the abnormal memory statistics obtained through /proc/pid/smaps In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> >> This was wrong from the very start. If we're not in GUP, we shouldn't call >> GUP functions. > > My understanding is !GET && !PIN is also called gup.. otherwise we don't > need GET and it can just be always implied. That's not the point. The point is that _arbitrary_ code shouldn't call into GUP internal helper functions, where they bypass, for example, any sanity checks. > > The other proof is try_grab_page() doesn't fail hard on !GET && !PIN. So I > don't know whether that's "wrong" to be used.. > To me, that is arbitrary code using a GUP internal helper and, therefore, wrong. > Back to the topic: I'd say either of the patches look good to solve the > problem. If p2pdma pages are mapped as PFNMAP/MIXEDMAP (?), I guess > vm_normal_page_pmd() proposed here will also work on it, so nothing I see > wrong on 2nd one yet. > > It looks nicer indeed to not have FOLL_FORCE here, but it also makes me > just wonder whether we should document NUMA behavior for FOLL_* somewhere, > because we have an implication right now on !FOLL_FORCE over NUMA, which is > not obvious to me.. Yes, we probably should. For get_use_pages() and friends that behavior was always like that and it makes sense: usually it represent application behavior. > > And to look more over that aspect, see follow_page(): previously we can > follow a page for protnone (as it never applies FOLL_NUMA) but now it won't > (it never applies FOLL_FORCE, either, so it seems "accidentally" implies > FOLL_NUMA now). Not sure whether it's intended, though.. That was certainly an oversight, thanks for spotting that. That patch was not supposed to change semantics: diff --git a/mm/gup.c b/mm/gup.c index 76d222ccc3ff..ac926e19ff72 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -851,6 +851,13 @@ struct page *follow_page(struct vm_area_struct *vma, unsigned long address, if (WARN_ON_ONCE(foll_flags & FOLL_PIN)) return NULL; + /* + * In contrast to get_user_pages() and friends, we don't want to + * fail if the PTE is PROT_NONE: see gup_can_follow_protnone(). + */ + if (!(foll_flags & FOLL_WRITE)) + foll_flags |= FOLL_FORCE; + page = follow_page_mask(vma, address, foll_flags, &ctx); if (ctx.pgmap) put_dev_pagemap(ctx.pgmap); -- Cheers, David / dhildenb