Path: csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod From: "Kirill A. Shutemov" Newsgroups: linux.kernel Subject: Re: [PATCH 2/4] mm: mlock: avoid increase mm->locked_vm on mlock() when already mlock2(,MLOCK_ONFAULT) Date: Tue, 30 Aug 2016 13:40:01 +0200 Message-ID: References: X-Original-To: wei.guo.simon@gmail.com Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MVSKoY24gHHF3uS+1xF2m17TiYYGZWyAjA9QS7DAv4I=; b=lw0BGLPyjfD/UhMRj+Ue/9HSvq9y0grQYn0AzICwEB9q8YQrYH0y8UzKVQUnoCVPmG fpG3TH1oofV+52oCsDWVbqVcFJ3YrEzcGGjIajY8yrcwONdqnE5Od8XGU5QKa16KWUbj RdrwuBlIXeWmdzHdVowM4gSlToQ6/OORdIyMDD6YzBM264ACXV2CuAUaF1N50EA/KpnA 4NdRnZf6O3vG+CdJQS8l9T9ecCYapSCPuMzujbY8/eXwAl9M5vFJvbJl89M5eQab11BZ K857CRyUuH/Rx5syuYYIHrlThHUv/T9gsMUNfaPU80yMQvkfHeqUW10mRAJDR1iRfU8r koog== X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=MVSKoY24gHHF3uS+1xF2m17TiYYGZWyAjA9QS7DAv4I=; b=UOmeJfCfNYPlhYEVmVYTFBMW3NED8ChC3CSJT25grTz1Pizaw0rkZmsvpCWph7GnZr YvRA+CwFXQkXCAQh97opYASuNMx6eUFsqTm7CoL2CZ+PKtbHAugF8oNs39N9CU1yYg6i IGiOIgdzer30xRg7nFb1yh6PqxHtU34iLjzpiYiYY3FV3/k0Lpiw5Ts89l9bOXmqBZ4C ed87MOK6bOxg9FqJKxoHxOpRnS3cQs1FglmKxYgQMhpZhP+xL6e8/8eFAgvQdf7SsZ+N G2T39bJxolztVCU/ovO05QOvAXQJz6HgE5nzIaVYIgmpl5zjt9oNfm5mUdTFvk0d605I dLBg== X-Gm-Message-State: AE9vXwM5KQck21EyQ+uqmVfkjzhO+P9zGr4Zx9dMS3RXgKOnYqQC2bBDzXwd5ulYmQyKjg== X-Received: by 10.25.126.2 with SMTP id z2mr976114lfc.195.1472557007137; Tue, 30 Aug 2016 04:36:47 -0700 (PDT) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 26 Organization: linux.* mail to news gateway X-Original-Cc: linux-mm@kvack.org, Alexey Klimov , Andrew Morton , Eric B Munson , Geert Uytterhoeven , "Kirill A. Shutemov" , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Mel Gorman , Michal Hocko , Shuah Khan , Thierry Reding , Vlastimil Babka X-Original-Date: Tue, 30 Aug 2016 14:36:44 +0300 X-Original-Message-ID: <20160830113644.GB32187@node.shutemov.name> X-Original-References: <1472554781-9835-1-git-send-email-wei.guo.simon@gmail.com> <1472554781-9835-3-git-send-email-wei.guo.simon@gmail.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1472427 On Tue, Aug 30, 2016 at 06:59:39PM +0800, wei.guo.simon@gmail.com wrote: > From: Simon Guo > > When one vma was with flag VM_LOCKED|VM_LOCKONFAULT (by invoking > mlock2(,MLOCK_ONFAULT)), it can again be populated with mlock() with > VM_LOCKED flag only. > > There is a hole in mlock_fixup() which increase mm->locked_vm twice even > the two operations are on the same vma and both with VM_LOCKED flags. > > The issue can be reproduced by following code: > mlock2(p, 1024 * 64, MLOCK_ONFAULT); //VM_LOCKED|VM_LOCKONFAULT > mlock(p, 1024 * 64); //VM_LOCKED > Then check the increase VmLck field in /proc/pid/status(to 128k). > > When vma is set with different vm_flags, and the new vm_flags is with > VM_LOCKED, it is not necessarily be a "new locked" vma. This patch > corrects this bug by prevent mm->locked_vm from increment when old > vm_flags is already VM_LOCKED. > > Signed-off-by: Simon Guo Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov