From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757726AbcILTKo (ORCPT ); Mon, 12 Sep 2016 15:10:44 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35190 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754778AbcILTKk (ORCPT ); Mon, 12 Sep 2016 15:10:40 -0400 Date: Mon, 12 Sep 2016 21:10:37 +0200 From: Michal Hocko To: Dave Hansen Cc: Xiao Guangrong , pbonzini@redhat.com, akpm@linux-foundation.org, dan.j.williams@intel.com, gleb@kernel.org, mtosatti@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, stefanha@redhat.com, yuhuang@redhat.com, linux-mm@kvack.org, ross.zwisler@linux.intel.com, Oleg Nesterov Subject: Re: [PATCH v2] mm, proc: Fix region lost in /proc/self/smaps Message-ID: <20160912191035.GD14997@dhcp22.suse.cz> References: <1473649964-20191-1-git-send-email-guangrong.xiao@linux.intel.com> <20160912125447.GM14524@dhcp22.suse.cz> <57D6C332.4000409@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57D6C332.4000409@intel.com> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 12-09-16 08:01:06, Dave Hansen wrote: > On 09/12/2016 05:54 AM, Michal Hocko wrote: > >> > In order to fix this bug, we make 'file->version' indicate the end address > >> > of current VMA > > Doesn't this open doors to another weird cases. Say B would be partially > > unmapped (tail of the VMA would get unmapped and reused for a new VMA. > > In the end, this interface isn't about VMAs. It's about addresses, and > we need to make sure that the _addresses_ coming out of it are sane. In > the case that a VMA was partially unmapped, it doesn't make sense to > show the "new" VMA because we already had some output covering the > address of the "new" VMA from the old one. OK, that is a fair point and it speaks for caching the vm_end rather than vm_start+skip. > > I am not sure we provide any guarantee when there are more read > > syscalls. Hmm, even with a single read() we can get inconsistent results > > from different threads without any user space synchronization. > > Yeah, very true. But, I think we _can_ at least provide the following > guarantees (among others): > 1. addresses don't go backwards > 2. If there is something at a given vaddr during the entirety of the > life of the smaps walk, we will produce some output for it. I guess we also want 3. no overlaps with previously printed values (assuming two subsequent reads without seek). the patch tries to achieve the last part as well AFAICS but I guess this is incomplete because at least /proc//smaps will report counters for the full vma range while the header (aka show_map_vma) will report shorter (non-overlapping) range. I haven't checked other files which use m_{start,next} Considering how this all can be tricky and how partial reads can be confusing and even misleading I am really wondering whether we should simply document that only full reads will provide a sensible results. -- Michal Hocko SUSE Labs