Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4169854pxj; Tue, 25 May 2021 01:50:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5O/5Ud5zWQhB1J7gVD1slZPuKIvHnQ0Qk7fVuKQqSa69qTuUfsWH/9yT/GpkIUbwnhS7g X-Received: by 2002:a17:906:ad9a:: with SMTP id la26mr28033013ejb.122.1621932645449; Tue, 25 May 2021 01:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621932645; cv=none; d=google.com; s=arc-20160816; b=Ihnjyk+V50nYvamhkmfdX+KoqFOM/4yhYRveP0iIIYbSdBE9yXNR62dNYMMHa78uy4 kpPYmkkREcAK7djbywIq+yaNQhZxASzxRD8nkKKtZqZIWojZRBCPgcir8zmXbi3re0// gsAX9Ey3LjUv+bYh8mVYTIHE8NZRkF6My17a2qr9ULGQ9atrnqlhkyrUVsFhY8cN9Mab qDxpl3M8EuMrcaW6ZaYgnQEeg6Gt3tIUR6qUtqYGlOftQUUwLs5IPo87i+Y2NLcYsK73 ezhqoFNVP0wXArMIPG/TVWNI8p3jcco/gBvZW23divXAWna48+QVN64Zk+tIje6etVDs NDWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=cBTpb8oJt9glxSCHDQUwIyXY+s7ZBCa51c0d2hwY7nc=; b=Llk+lF1UYW1bZdmoAoy4NuvBMCerwPmVJhmgvIY1EaJKYTcedFQ9uNdVxbiBki5YQp /AT6KFhQC22PyZDbNcvs7J8k/ZPDMXJEeeujp8rnyqfDbgSO4F1NDU5L1YCT8GU3Qt3W HLpul8dOfOnCgA2mUzuiKYSM1rv/Ra4QV0JdxB+OiZPxn+lLMovnkqSQB9Ku5PGTw6PN ijJhk4SR0S6DgNsV2IQ8gAdMoCeGqtOKSqVZsOXFLanY9XraN6dDDObuLNhK3GP1xLTf qVC78SMsKr0ZHvB6M9vfCEkVg36hpn2F5zsV9q3zWCIsWupVfzH2iWZz6ui0FPtFpqL0 vw7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=EczqhsS4; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="5LG/R/yA"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si16418392edi.123.2021.05.25.01.50.22; Tue, 25 May 2021 01:50:45 -0700 (PDT) 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=@suse.de header.s=susede2_rsa header.b=EczqhsS4; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="5LG/R/yA"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232184AbhEYISD (ORCPT + 99 others); Tue, 25 May 2021 04:18:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:56944 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbhEYISB (ORCPT ); Tue, 25 May 2021 04:18:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1621930591; h=from:from:reply-to: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=cBTpb8oJt9glxSCHDQUwIyXY+s7ZBCa51c0d2hwY7nc=; b=EczqhsS4/Xi3ikRA8F8oPMZV5MYYAX6lPTn7KdzPl6WKUo7l+wWnC/B0mSH22rgXmtA055 kbLbdsKFvk65GV0LQe4n+vLdoQpePZu/j3Z4wWLqjiznCeXoRbgJ2pokf81wy9ezABhoY8 FBdCmL9X+POMWP7GrVxBuomgcWzVcoQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1621930591; h=from:from:reply-to: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=cBTpb8oJt9glxSCHDQUwIyXY+s7ZBCa51c0d2hwY7nc=; b=5LG/R/yAUM5v9t0s1VF4gwLYCBRdG0N9ggk+VBmXNocCPcVfvBwWckPOqjt4TIl5jBI+pv nAJF0QhPxrXz9NCQ== Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1C9ACAE1F; Tue, 25 May 2021 08:16:31 +0000 (UTC) Date: Tue, 25 May 2021 10:16:26 +0200 From: Oscar Salvador To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, Andrew Morton , "Michael S. Tsirkin" , Jason Wang , Alexey Dobriyan , Mike Rapoport , "Matthew Wilcox (Oracle)" , Michal Hocko , Roman Gushchin , Alex Shi , Steven Price , Mike Kravetz , Aili Yao , Jiri Bohac , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Naoya Horiguchi , linux-hyperv@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 4/6] mm: introduce page_offline_(begin|end|freeze|thaw) to synchronize setting PageOffline() Message-ID: <20210525081626.GB3300@linux> References: <20210514172247.176750-1-david@redhat.com> <20210514172247.176750-5-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210514172247.176750-5-david@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 14, 2021 at 07:22:45PM +0200, David Hildenbrand wrote: > A driver might set a page logically offline -- PageOffline() -- and > turn the page inaccessible in the hypervisor; after that, access to page > content can be fatal. One example is virtio-mem; while unplugged memory > -- marked as PageOffline() can currently be read in the hypervisor, this > will no longer be the case in the future; for example, when having > a virtio-mem device backed by huge pages in the hypervisor. > > Some special PFN walkers -- i.e., /proc/kcore -- read content of random > pages after checking PageOffline(); however, these PFN walkers can race > with drivers that set PageOffline(). > > Let's introduce page_offline_(begin|end|freeze|thaw) for > synchronizing. > > page_offline_freeze()/page_offline_thaw() allows for a subsystem to > synchronize with such drivers, achieving that a page cannot be set > PageOffline() while frozen. > > page_offline_begin()/page_offline_end() is used by drivers that care about > such races when setting a page PageOffline(). > > For simplicity, use a rwsem for now; neither drivers nor users are > performance sensitive. > > Acked-by: Michal Hocko > Signed-off-by: David Hildenbrand Reviewed-by: Oscar Salvador -- Oscar Salvador SUSE L3