Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2379781pxj; Sun, 16 May 2021 23:48:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzY3TN9211X3Dz2yOzIMmVMuLvf3i1gPF27D7LXBvWUGltPj+Fw1HiADJX1YV2qgV9dDgq3 X-Received: by 2002:a5d:87c4:: with SMTP id q4mr41583116ios.141.1621234113932; Sun, 16 May 2021 23:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621234113; cv=none; d=google.com; s=arc-20160816; b=rkvlcqzuGau5EiYptA1Jw1ga6zZNu1/HxVWolWbPDLP+xXUzFieprxgFz0DsQf05GW Y6NEk2C05y4EwCJQLv1Y+EyI3mRLKQjtBB+RCzwcGSNGl7gncwwuLhShEtwrc7rhth2F qGVgxb1dZpUL5nI9QB0Qy7k+zrSmmvYoTbBz6ZZ1A5EoUZ9BMAtkrNtkPXv6qYnITwST BuQ6OnoyN4HL+tDZyzyr7GWvOOa2fr5a2aqAftFe3r7w2jzhS3egYVvqB0ULfLwQsjZ2 CdxNKWr5/flsqInXQHPIR9QrbRrScyrB1c6dm5nxLp/Ulz1JtTQDA4aoGYjoIW6CdfaW Zcmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ufXxV+TkVdJwzfzAxoPW2Kg3j1UObihcP0R0O8J3Tmo=; b=BxuHFCitjpr6OHQkr0/jwIadxVRjkxPImGarSUEhEf8NPGkKQLrug8FPWM9g/SFt9Q xbwvTvAEr+kBcyKCtAGouPKMA+Gd7njgBF2VDWepzSdgKNUrT98ahHE4QcTcNI/8YiJH CD0ojL3vRoNiTde15ROHphMZkD6FNQS7ZGaI8o9Z+3mh+a0RmHcuUvxR5mL8gOIfxMJ9 yL/4Z8A/MQvnTe0kgbg0ytx4YWAL2tvwc08UCJ5nOu0R0aOCZs14XbyVdq/wnCESlvXb zGHWk+0wED1L4AcDEa2fJ7HTz5yiVSneYQarPKVCSPbznqJNd8i+qwIWbJPhsllTIipT 5ZaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ObtoQIRN; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x5si17781218ilu.59.2021.05.16.23.48.20; Sun, 16 May 2021 23:48:33 -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=@kernel.org header.s=k20201202 header.b=ObtoQIRN; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234458AbhEQGpu (ORCPT + 99 others); Mon, 17 May 2021 02:45:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:43896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233763AbhEQGpt (ORCPT ); Mon, 17 May 2021 02:45:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6480561241; Mon, 17 May 2021 06:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621233873; bh=T9ZQTSZNUgScjjscUGeUbBchpa/DhX2GQEJ7bdtNzBA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ObtoQIRNWxRguTgHnVfCVu7AKOk3Iw7wF8fqwXQR/rPc0nGO5+s6yg3D0U2vm3aT7 XNy69ebRGLwVhrw9OWXJc0sPi4ha8KBWwsP8N1fFaZRMnjxf53cZ73/ij16KbQsw7l qZLKTKAD/Y2WbMMKFozt11phpM+mqIuImeNnmHBOt55cZXZ/9Ln9YjnZfxM0uI2IHE dpF29d0QZOKhpr05D/dOT1ho7DzutPkIeIrZw0sR6BleZy18PGvtN0RG57oGn8V+uR Pyn+1fmOk1a++kAEZEhqjiQGECWaRP/TYpyn+ShcWYJbNSGpgi59bEt9AD/EQ3j0cB RDY5jYDTRUnqQ== Date: Mon, 17 May 2021 09:44:21 +0300 From: Mike Rapoport To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, Andrew Morton , "Michael S. Tsirkin" , Jason Wang , Alexey Dobriyan , "Matthew Wilcox (Oracle)" , Oscar Salvador , 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 6/6] fs/proc/kcore: use page_offline_(freeze|thaw) Message-ID: References: <20210514172247.176750-1-david@redhat.com> <20210514172247.176750-7-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210514172247.176750-7-david@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 14, 2021 at 07:22:47PM +0200, David Hildenbrand wrote: > Let's properly synchronize with drivers that set PageOffline(). > Unfreeze/thaw every now and then, so drivers that want to set PageOffline() > can make progress. > > Signed-off-by: David Hildenbrand Acked-by: Mike Rapoport > --- > fs/proc/kcore.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c > index 92ff1e4436cb..982e694aae77 100644 > --- a/fs/proc/kcore.c > +++ b/fs/proc/kcore.c > @@ -313,6 +313,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) > { > char *buf = file->private_data; > size_t phdrs_offset, notes_offset, data_offset; > + size_t page_offline_frozen = 1; > size_t phdrs_len, notes_len; > struct kcore_list *m; > size_t tsz; > @@ -322,6 +323,11 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) > int ret = 0; > > down_read(&kclist_lock); > + /* > + * Don't race against drivers that set PageOffline() and expect no > + * further page access. > + */ > + page_offline_freeze(); > > get_kcore_size(&nphdr, &phdrs_len, ¬es_len, &data_offset); > phdrs_offset = sizeof(struct elfhdr); > @@ -480,6 +486,12 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) > } > } > > + if (page_offline_frozen++ % MAX_ORDER_NR_PAGES == 0) { > + page_offline_thaw(); > + cond_resched(); > + page_offline_freeze(); > + } > + > if (&m->list == &kclist_head) { > if (clear_user(buffer, tsz)) { > ret = -EFAULT; > @@ -565,6 +577,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) > } > > out: > + page_offline_thaw(); > up_read(&kclist_lock); > if (ret) > return ret; > -- > 2.31.1 > -- Sincerely yours, Mike.