From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752027AbcFUPiI (ORCPT ); Tue, 21 Jun 2016 11:38:08 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:35757 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751719AbcFUPhw (ORCPT ); Tue, 21 Jun 2016 11:37:52 -0400 Date: Tue, 21 Jun 2016 17:37:01 +0300 From: "Kirill A. Shutemov" To: zhongjiang Cc: mhocko@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/huge_memory: fix the memory leak due to the race Message-ID: <20160621143701.GA6139@node.shutemov.name> References: <1466517956-13875-1-git-send-email-zhongjiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1466517956-13875-1-git-send-email-zhongjiang@huawei.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, Jun 21, 2016 at 10:05:56PM +0800, zhongjiang wrote: > From: zhong jiang > > with great pressure, I run some test cases. As a result, I found > that the THP is not freed, it is detected by check_mm(). > > BUG: Bad rss-counter state mm:ffff8827edb70000 idx:1 val:512 > > Consider the following race : > > CPU0 CPU1 > __handle_mm_fault() > wp_huge_pmd() > do_huge_pmd_wp_page() > pmdp_huge_clear_flush_notify() > (pmd_none = true) > exit_mmap() > unmap_vmas() > zap_pmd_range() > pmd_none_or_trans_huge_or_clear_bad() > (result in memory leak) > set_pmd_at() > > because of CPU0 have allocated huge page before pmdp_huge_clear_notify, > and it make the pmd entry to be null. Therefore, The memory leak can occur. > > The patch fix the scenario that the pmd entry can lead to be null. I don't think the scenario is possible. exit_mmap() called when all mm users have gone, so no parallel threads exist. -- Kirill A. Shutemov