From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933134AbcFBS4i (ORCPT ); Thu, 2 Jun 2016 14:56:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39358 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933053AbcFBS4h (ORCPT ); Thu, 2 Jun 2016 14:56:37 -0400 Message-Id: <201606021856.u52Ik7dd033233@mx0a-001b2d01.pphosted.com> X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: borntraeger@de.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Subject: Re: [BUG/REGRESSION] THP: broken page count after commit aa88b68c To: Andrew Morton , "Kirill A. Shutemov" References: <20160602172141.75c006a9@thinkpad> <20160602155149.GB8493@node.shutemov.name> <20160602114031.64b178c823901c171ec82745@linux-foundation.org> Cc: Gerald Schaefer , "Kirill A. Shutemov" , Andrea Arcangeli , "Aneesh Kumar K.V" , Mel Gorman , Hugh Dickins , Johannes Weiner , Dave Hansen , Vlastimil Babka , Linus Torvalds , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Martin Schwidefsky , Heiko Carstens From: Christian Borntraeger Date: Thu, 2 Jun 2016 20:56:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <20160602114031.64b178c823901c171ec82745@linux-foundation.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16060218-0040-0000-0000-000001E61AAA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16060218-0041-0000-0000-0000207A0370 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-06-02_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=25 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606020222 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/02/2016 08:40 PM, Andrew Morton wrote: > On Thu, 2 Jun 2016 18:51:50 +0300 "Kirill A. Shutemov" wrote: > >> On Thu, Jun 02, 2016 at 05:21:41PM +0200, Gerald Schaefer wrote: >>> Christian Borntraeger reported a kernel panic after corrupt page counts, >>> and it turned out to be a regression introduced with commit aa88b68c >>> "thp: keep huge zero page pinned until tlb flush", at least on s390. >>> >>> put_huge_zero_page() was moved over from zap_huge_pmd() to release_pages(), >>> and it was replaced by tlb_remove_page(). However, release_pages() might >>> not always be triggered by (the arch-specific) tlb_remove_page(). >>> >>> On s390 we call free_page_and_swap_cache() from tlb_remove_page(), and not >>> tlb_flush_mmu() -> free_pages_and_swap_cache() like the generic version, >>> because we don't use the MMU-gather logic. Although both functions have very >>> similar names, they are doing very unsimilar things, in particular >>> free_page_xxx is just doing a put_page(), while free_pages_xxx calls >>> release_pages(). >>> >>> This of course results in very harmful put_page()s on the huge zero page, >>> on architectures where tlb_remove_page() is implemented in this way. It >>> seems to affect only s390 and sh, but sh doesn't have THP support, so >>> the problem (currently) probably only exists on s390. >>> >>> The following quick hack fixed the issue: >>> >>> diff --git a/mm/swap_state.c b/mm/swap_state.c >>> index 0d457e7..c99463a 100644 >>> --- a/mm/swap_state.c >>> +++ b/mm/swap_state.c >>> @@ -252,7 +252,10 @@ static inline void free_swap_cache(struct page *page) >>> void free_page_and_swap_cache(struct page *page) >>> { >>> free_swap_cache(page); >>> - put_page(page); >>> + if (is_huge_zero_page(page)) >>> + put_huge_zero_page(); >>> + else >>> + put_page(page); >>> } >>> >>> /* >> >> The fix looks good to me. > > Yes. A bit regrettable, but that's what release_pages() does. > > Can we have a signed-off-by please? Please also add CC: stable for 4.6