Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3708640imu; Fri, 30 Nov 2018 04:56:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/WeGIRfOOl4Yp5ftE85W/mbJUOHOmvs/B1ZUAsTNj2g+gpYz77kgswBm64+jXovr813E7jr X-Received: by 2002:a17:902:b118:: with SMTP id q24mr5656736plr.209.1543582590652; Fri, 30 Nov 2018 04:56:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543582590; cv=none; d=google.com; s=arc-20160816; b=Xbly5LVV/l+3T7WY71OW/Lk3FA4TMHe7vfeTntRi15RJFg4CFHdSCQq6SDl/WKCsoU 3LC4Pn5LsU0SXioREgPkb82dmY6ALrzabVFmF3noUia4XWBjesp1VFJBxk/HORFlBAwV A0kYusPy7Oy84orO3dzlKsoQDu6PZWjqRt3FjlUNZ3+c6R5O8/5hWux65ULW3mVmnJ/R ly21zKhp6/q7XICRdrZ1T5yQ2mI/n0RG2we0oc2TKYXvDtBNr92z2Eqch8cb4rDKUIqr +pOQxXK3wQ9t7qPSxQNdel5UN8JpxJMFwaCUBEV43wQSp8hTps4qJ1lu9RGvKG1HzoIx /CcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=XKds6rNpspkDTr2LIhhuAY5+8Tr4GYAAAU9n31DCOAk=; b=FJw+3VJIpxqy5/gLOf0i9bSkYg9GwwrobCeeJY+U5psfzoFYAIYFYCyv95ps0wlkZ/ dBC6S7o2rlWDQwqb3E9/dAOfM/xk7AgnsT+YNa22HQYJvTV++7tkg1T2zt5g3BAaeqdM RE6AhU3kpAXb/B3dwE0Iy+AEZe0gFiXYxR/tLFZ+6kw0Mrj4TtZ6yHRH5k2VPkwXYkIT HwpG8oWISh00FpMmE9uloI3SEjBZ6IePVyCpdqYXE6NxAZ1zr+BMR0HyeCvkO/YIlO9q yCUMI60mUfvdFrSlNqfCZ8/TxXoICAhgqVmle7tKOuGJG+YD6ywof4mynDIBG64ZotcX SLUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=QhPvVtgR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s123si5299646pfb.274.2018.11.30.04.56.14; Fri, 30 Nov 2018 04:56:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=QhPvVtgR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726519AbeLAAEs (ORCPT + 99 others); Fri, 30 Nov 2018 19:04:48 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:40702 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726292AbeLAAEs (ORCPT ); Fri, 30 Nov 2018 19:04:48 -0500 Received: by mail-pl1-f193.google.com with SMTP id u18so2773014plq.7 for ; Fri, 30 Nov 2018 04:55:35 -0800 (PST) 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=XKds6rNpspkDTr2LIhhuAY5+8Tr4GYAAAU9n31DCOAk=; b=QhPvVtgRFjAavQn4beDykDWAJvtU/BjSEuctDTi+0SEQJe8MZCJkScbnqFDq04JOkY syqm+zdwAsDh+slytPV+5w6gzDfiX6abBZe5b2nnv/TRvsGaWWYNXXWrp1LqCWwVGAai +NVabOmZEmHwb9ma7DnNsNK88qkhfCqVr4ij9vz/vjtIde0EPs99fCIEzhzjZTuPOkiH sLFxakj8aur1J4rREs5+LzGVxZ2yARGD+B/mHyElCHqFTqOfpeIKdlcGo6ydS3hHLMFa 2nH+FJD6KbbNYpnEsAVap5kCAUlo62BgUisOK3Azm/2qg08mAqEZElxh9aKmm8BFRb9Q Xh0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XKds6rNpspkDTr2LIhhuAY5+8Tr4GYAAAU9n31DCOAk=; b=Pf/T4IICaM0TA9cpcvoxuPdzUXaxOhdaKsDzJkptw6u4jklVQRFhTBzgBdF14V7yyA LtQk/frJpPuqbZpzelIYfjXvIbV/f6CboPKRylb7vweCEtPoCRcz6vWgXMqqpR3F4Hz9 Cdsy88kinlr3krMLcm6UJW7b3CRPEpvrcwVNihv703slZYtuKmsvI5volE1aG9T42fRq ENeZh66uXVZYL6zpuI9lD/NK9qs58dpx2mUozh5SqK2ZNxpJvUQq8ZuaUaTiBkblS3tY lIvS3KzvZNO7hTZilH8H/Q8G2Q6NN5i1YiuVC5pFpasNBOw0aAid9/t5KRg5pScgjzXE dvkg== X-Gm-Message-State: AA+aEWbMY/Ir0bt/3b7TBxxTV5tlxWjt4rcluVoYEgrV20+E8CEEetva lJ0H7QI4cvteYHfo3WIN2EROgg== X-Received: by 2002:a17:902:8ec8:: with SMTP id x8mr5636985plo.210.1543582535128; Fri, 30 Nov 2018 04:55:35 -0800 (PST) Received: from kshutemo-mobl1.localdomain ([134.134.139.82]) by smtp.gmail.com with ESMTPSA id v13sm7252341pff.20.2018.11.30.04.55.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 04:55:34 -0800 (PST) Received: by kshutemo-mobl1.localdomain (Postfix, from userid 1000) id A6A7B30042C; Fri, 30 Nov 2018 15:55:29 +0300 (+03) Date: Fri, 30 Nov 2018 15:55:29 +0300 From: "Kirill A. Shutemov" To: Michal Hocko Cc: Jan Stancek , linux-mm@kvack.org, lersek@redhat.com, alex.williamson@redhat.com, aarcange@redhat.com, rientjes@google.com, mgorman@techsingularity.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm: page_mapped: don't assume compound page is huge or THP Message-ID: <20181130125529.6lw2xqiccnoddrvj@kshutemo-mobl1> References: <20181130121851.GI6923@dhcp22.suse.cz> <20181130123651.5qrdrw3i5ergbuzl@kshutemo-mobl1> <20181130124546.GJ6923@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181130124546.GJ6923@dhcp22.suse.cz> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 30, 2018 at 01:45:46PM +0100, Michal Hocko wrote: > On Fri 30-11-18 15:36:51, Kirill A. Shutemov wrote: > > On Fri, Nov 30, 2018 at 01:18:51PM +0100, Michal Hocko wrote: > > > On Fri 30-11-18 13:06:57, Jan Stancek wrote: > > > > LTP proc01 testcase has been observed to rarely trigger crashes > > > > on arm64: > > > > page_mapped+0x78/0xb4 > > > > stable_page_flags+0x27c/0x338 > > > > kpageflags_read+0xfc/0x164 > > > > proc_reg_read+0x7c/0xb8 > > > > __vfs_read+0x58/0x178 > > > > vfs_read+0x90/0x14c > > > > SyS_read+0x60/0xc0 > > > > > > > > Issue is that page_mapped() assumes that if compound page is not > > > > huge, then it must be THP. But if this is 'normal' compound page > > > > (COMPOUND_PAGE_DTOR), then following loop can keep running > > > > (for HPAGE_PMD_NR iterations) until it tries to read from memory > > > > that isn't mapped and triggers a panic: > > > > for (i = 0; i < hpage_nr_pages(page); i++) { > > > > if (atomic_read(&page[i]._mapcount) >= 0) > > > > return true; > > > > } > > > > > > > > I could replicate this on x86 (v4.20-rc4-98-g60b548237fed) only > > > > with a custom kernel module [1] which: > > > > - allocates compound page (PAGEC) of order 1 > > > > - allocates 2 normal pages (COPY), which are initialized to 0xff > > > > (to satisfy _mapcount >= 0) > > > > - 2 PAGEC page structs are copied to address of first COPY page > > > > - second page of COPY is marked as not present > > > > - call to page_mapped(COPY) now triggers fault on access to 2nd > > > > COPY page at offset 0x30 (_mapcount) > > > > > > > > [1] https://github.com/jstancek/reproducers/blob/master/kernel/page_mapped_crash/repro.c > > > > > > > > Fix the loop to iterate for "1 << compound_order" pages. > > > > > > This is much less magic than the previous version. It is still not clear > > > to me how is mapping higher order pages to page tables other than THP > > > though. So a more detailed information about the source would bre really > > > welcome. Once we know that we can add a Fixes tag and also mark the > > > patch for stable because that sounds like a stable material. > > > > IIRC, sound subsystem can producuce custom mapped compound pages. > > Do I assume correctly that consecutive ptes simply point to subpages? Yes. No huge pages there. -- Kirill A. Shutemov