From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758289AbcH3Lgv (ORCPT ); Tue, 30 Aug 2016 07:36:51 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:33558 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757406AbcH3Lgs (ORCPT ); Tue, 30 Aug 2016 07:36:48 -0400 Date: Tue, 30 Aug 2016 14:36:44 +0300 From: "Kirill A. Shutemov" To: wei.guo.simon@gmail.com 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 Subject: Re: [PATCH 2/4] mm: mlock: avoid increase mm->locked_vm on mlock() when already mlock2(,MLOCK_ONFAULT) Message-ID: <20160830113644.GB32187@node.shutemov.name> References: <1472554781-9835-1-git-send-email-wei.guo.simon@gmail.com> <1472554781-9835-3-git-send-email-wei.guo.simon@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1472554781-9835-3-git-send-email-wei.guo.simon@gmail.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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