Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp243220pxb; Fri, 15 Jan 2021 11:51:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPzOaGxOsMDIXIcBfjZah44sjM53sGO393XDBaK/0sgA6fXNY2S20oPuRp1ODxwBmgSy8k X-Received: by 2002:aa7:db14:: with SMTP id t20mr10850444eds.158.1610740295160; Fri, 15 Jan 2021 11:51:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610740295; cv=none; d=google.com; s=arc-20160816; b=q/nM5uTB1fhMoG6hb+8wgLb2m4bD21sdvu9rjOzPHkrQidUBneQNm3KZXAE8FXKiJg ikpD/E3qlb+1L6OqMBaAv/86HqYLp+cVAPuLSXQSnDIzdMEbgdsVMbkbQsH1ewClbvtX Wcm648gAT5KjoS0kbQFL6lS3f4XG4fhlyKqDeZlKrZXfjrAlSHsm5yX8K18zYvmf1xsr qMInKOayi+j+QcS+gZNI/YDLrZo8EMjNgoTCNwXau9RLBuCGn1nUw2ojjjMruo+pD13+ eD6R+j9cGzjjVFmK1FOlPQesDddsb8GvI7eioRtwwEyCb6JMswYtIEdYSFfQTbbXq1ta x/ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=CqTXrqY5WOpLVbfIkQazPRNF8DOg7J3nam2cFtoi1LU=; b=OxX86L8z3/aVOQVHuLw5NbKSjQLt4NWcD57xHKiZCXFXBN895zNp1Ryn3ppIoMfIxD NXvJytObbjv7AUrQnLQn/gD8CRjOUhQa9spLQtkJFgOCFscFxXapMJVlQnghlbgDV2Mv jGPSbeLRWhhIov7buPhFaY15OD4hP3wzjD8D0ioJSTBd88GYiB3z4vJrfOrl+m0KkWHG swzC7qiTnMSLZkGyErH9qs3RnOLKN8DhUBACAadqWNcxRgV8mjQ/7HBCh304SZMpyxl5 vVXyKIZAoHOvJogxxhqOiCNtMTlT+1o1OKyV/rHJk0YBjeF+BB2B4e/WU7F9Dr55qcLI gtDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cXLUFklE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si4649744ejd.570.2021.01.15.11.51.11; Fri, 15 Jan 2021 11:51:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cXLUFklE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2388221AbhAOTsp (ORCPT + 99 others); Fri, 15 Jan 2021 14:48:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:53570 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726815AbhAOTsf (ORCPT ); Fri, 15 Jan 2021 14:48:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610740028; 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=CqTXrqY5WOpLVbfIkQazPRNF8DOg7J3nam2cFtoi1LU=; b=cXLUFklEXzNiSYQcZgcq6xjhVpcikBxr2TH/FiNSKpLhOkEqInxiaI54zC8Buuaf/Lqhu3 gIxLjr6xVS1N1pQtYpdH9ZupKSvIrtsc5Hct1Yxty0hjCJW30YeuKb22Tc+Swv/WKtrQLC hsqPWb6qEBwvL4V/El4dc7hrZmxvsgA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-lwD9702uPka_VHursUlkEQ-1; Fri, 15 Jan 2021 14:47:06 -0500 X-MC-Unique: lwD9702uPka_VHursUlkEQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1CF7D18C89E4; Fri, 15 Jan 2021 19:47:03 +0000 (UTC) Received: from [10.36.112.11] (ovpn-112-11.ams2.redhat.com [10.36.112.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFDFD60BF3; Fri, 15 Jan 2021 19:46:49 +0000 (UTC) Subject: Re: [PATCH 0/1] mm: restore full accuracy in COW page reuse To: Jason Gunthorpe Cc: Andrea Arcangeli , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao , Andy Lutomirski , Peter Xu , Pavel Emelyanov , Mike Kravetz , Mike Rapoport , Minchan Kim , Will Deacon , Peter Zijlstra , Linus Torvalds , Hugh Dickins , "Kirill A. Shutemov" , Matthew Wilcox , Oleg Nesterov , Jann Horn , Kees Cook , John Hubbard , Leon Romanovsky , Jan Kara , Kirill Tkhai , Nadav Amit , Jens Axboe References: <20210110004435.26382-1-aarcange@redhat.com> <20210115183721.GG4605@ziepe.ca> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Fri, 15 Jan 2021 20:46:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20210115183721.GG4605@ziepe.ca> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> 7) There is no easy way to detect if a page really was pinned: we might >> have false positives. Further, there is no way to distinguish if it was >> pinned with FOLL_WRITE or not (R vs R/W). To perform reliable tracking >> we most probably would need more counters, which we cannot fit into >> struct page. (AFAIU, for huge pages it's easier). > > I think this is the real issue. We can only store so much information, > so we have to decide which things work and which things are broken. So > far someone hasn't presented a way to record everything at least.. I do wonder how many (especially long-term) GUP readers/writers we have to expect, and especially, support for a single base page. Do we have a rough estimate? With RDMA, I would assume we only need a single one (e.g., once RDMA device; I'm pretty sure I'm wrong, sounds too easy). With VFIO I guess we need one for each VFIO container (~ in the worst case one for each passthrough device). With direct I/O, vmsplice and other GUP users ?? No idea. If we could somehow put a limit on the #GUP we support, and fail further GUP (e.g., -EAGAIN?) once a limit is reached, we could partition the refcount into something like (assume max #15 GUP READ and #15 GUP R/W, which is most probably a horribly bad choice) [ GUP READ ][ GUP R/W ] [ ordinary ] 31 ... 28 27 ... 24 23 .... 0 But due to saturate handling in "ordinary", we would lose further 2 bits (AFAIU), leaving us "only" 22 bits for "ordinary". Now, I have no idea how many bits we actually need in practice. Maybe we need less for GUP READ, because most users want GUP R/W? No idea. Just wild ideas. Most probably that has already been discussed, and most probably people figured that it's impossible :) -- Thanks, David / dhildenb