Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934018AbbGVKmc (ORCPT ); Wed, 22 Jul 2015 06:42:32 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:37692 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933440AbbGVKmb (ORCPT ); Wed, 22 Jul 2015 06:42:31 -0400 Date: Wed, 22 Jul 2015 13:42:26 +0300 From: "Kirill A. Shutemov" To: Eric B Munson Cc: Andrew Morton , Michal Hocko , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V4 1/6] mm: mlock: Refactor mlock, munlock, and munlockall code Message-ID: <20150722104226.GA8630@node.dhcp.inet.fi> References: <1437508781-28655-1-git-send-email-emunson@akamai.com> <1437508781-28655-2-git-send-email-emunson@akamai.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437508781-28655-2-git-send-email-emunson@akamai.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 Content-Length: 1243 Lines: 45 On Tue, Jul 21, 2015 at 03:59:36PM -0400, Eric B Munson wrote: > @@ -648,20 +656,23 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len) > start &= PAGE_MASK; > > down_write(¤t->mm->mmap_sem); > - ret = do_mlock(start, len, 0); > + ret = apply_vma_flags(start, len, flags, false); > up_write(¤t->mm->mmap_sem); > > return ret; > } > > +SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len) > +{ > + return do_munlock(start, len, VM_LOCKED); > +} > + > static int do_mlockall(int flags) > { > struct vm_area_struct * vma, * prev = NULL; > > if (flags & MCL_FUTURE) > current->mm->def_flags |= VM_LOCKED; > - else > - current->mm->def_flags &= ~VM_LOCKED; I think this is wrong. With current code mlockall(MCL_CURRENT) after mlockall(MCL_FUTURE | MCL_CURRENT) would undo future mlocking, without unlocking currently mlocked memory. The change will break the use-case. > if (flags == MCL_FUTURE) > goto out; > -- Kirill A. Shutemov -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/