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 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D29F6C433DB for ; Thu, 11 Mar 2021 21:26:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 17E5C64F9F for ; Thu, 11 Mar 2021 21:26:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17E5C64F9F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKSp1-0000Ad-0C for qemu-devel@archiver.kernel.org; Thu, 11 Mar 2021 16:26:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKSnz-0007mi-QQ for qemu-devel@nongnu.org; Thu, 11 Mar 2021 16:25:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21776) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKSnw-0003aL-JI for qemu-devel@nongnu.org; Thu, 11 Mar 2021 16:25:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615497910; 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=SI9Cd+F/EoZ6JbOVOMbCkIAvXnFvdA7omopBRBlkjtg=; b=DtauHmuz/nlHMKFeBdfT/YjTVSOYbOwDSIPFxp35XcnSPktIuPzWQs8mjjVKYLUhyEX2h8 pUjGQZ+upQ6rKtZ0ffyq7q+GIk1r8VGtkNFuK3QnkOGVe03XiT/81wU6ytdimrSQy9m5b8 pujxl/Hf9yaEKrd3lMUDic8Tm5SmKWw= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-tTpmMo-BPJazURVS7jWxug-1; Thu, 11 Mar 2021 16:25:09 -0500 X-MC-Unique: tTpmMo-BPJazURVS7jWxug-1 Received: by mail-qk1-f197.google.com with SMTP id b78so16658825qkg.13 for ; Thu, 11 Mar 2021 13:25:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SI9Cd+F/EoZ6JbOVOMbCkIAvXnFvdA7omopBRBlkjtg=; b=dg3SQ/ja6pEcwQOfxzsgcxlwsOBQ+5M5LdPDdJqg54UCfgk9tjQKxNG3oJ9VSLAFl6 /mJOilUwmX+Wcx70+PUWZl6auccR7JJLSNOBagQydtu2kJQV+nNKY7lsxFW6Iczorr1w VizZu3tOMYYonjAwRz+jSmG5ewRz///am74ywu5AmqPMoSYs2SQ+DssHTu5Xk5Y4JTwX T8xxYvm0KjiJOHmeyNfDGPnjJG1yqVm+XoS+qUPhnscy+6dd5G86ncbOAru2VVbF5uei ZVpsgj23C8Z/O1YBBotGucpUYJbyttDRwjGEtebnQ8/gum8suTP+sDofMCK7DrJTQddF JxFQ== X-Gm-Message-State: AOAM5336ouv6eawSEY2PHsxDWwkbY5d6rqB7L/tyaxBQOJAgivefmphx sk8EwYcgMi+ohClCMAQ3SXKWVV4Qhvf4hlFuLVyBJVNXq5M/hW456CamnvKDBkopOzmv0pzL/2h ed3TdiUIR7SsK4OU= X-Received: by 2002:ac8:7281:: with SMTP id v1mr1626263qto.302.1615497908773; Thu, 11 Mar 2021 13:25:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwoEkJJ0ZACUEQEKnxUE67lnlmb2xAEhk3N6n/rcaLS9W6OEdtCTH/pbjV13y8kR5HcMIMwNw== X-Received: by 2002:ac8:7281:: with SMTP id v1mr1626251qto.302.1615497908537; Thu, 11 Mar 2021 13:25:08 -0800 (PST) Received: from xz-x1 ([142.126.89.138]) by smtp.gmail.com with ESMTPSA id e190sm2859925qkd.122.2021.03.11.13.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 13:25:07 -0800 (PST) Date: Thu, 11 Mar 2021 16:25:05 -0500 From: Peter Xu To: David Hildenbrand Subject: Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory Message-ID: <20210311212505.GJ194839@xz-x1> References: <20210308150600.14440-1-david@redhat.com> <20210308150600.14440-3-david@redhat.com> <20210311171153.GF194839@xz-x1> <26d2c57a-971d-3abd-6ec3-1a38fb47a398@redhat.com> <20210311172236.GG194839@xz-x1> MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Cornelia Huck , Eduardo Habkost , "Michael S. Tsirkin" , Stefan Weil , Murilo Opsfelder Araujo , Richard Henderson , "Dr. David Alan Gilbert" , Juan Quintela , qemu-devel@nongnu.org, Halil Pasic , Christian Borntraeger , Greg Kurz , Stefan Hajnoczi , Igor Mammedov , Thomas Huth , Paolo Bonzini , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Igor Kotrasinski Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Thu, Mar 11, 2021 at 06:41:29PM +0100, David Hildenbrand wrote: > It zaps the page tables but the shmem pages are still referenced (in the > pagecache AFAIU). On next user space access, you would fill the page tables > with the previous content. > > That's why MADV_DONTNEED works properly on private anonymous memory, but not > on shared anonymous memory - the only valid references are in the page > tables in case of private mappings (well, unless we have other references > like GUP etc.). For some reason I thought anonymous shared memory could do auto-recycle, but after a second thought what you said makes perfect sense. > > > I did wonder, however, if there is benefit in doing both: > > MADV_REMOVE followed by MADV_DONTNEED or the other way around. Like, will > the extra MADV_DONTNEED also remove page tables and not just invalidate/zap > the entries. Doesn't make a difference functionality-wise, but > memory-consumption-wise. > > I'll still have to have a look. I saw your other email - that'll be another topic of course. For now I believe it's not necessary, and your current patch looks valid. I just hope when qemu decides to disgard the range, we're sure the rdma mremap() region have been unmaped - iiuc that's the only use case of that. Otherwise data would corrupt. -- Peter Xu