From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69B9EC43461 for ; Fri, 11 Sep 2020 14:34:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AB948222BA for ; Fri, 11 Sep 2020 14:34:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="n2C7UIY2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB948222BA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B117F6B0003; Fri, 11 Sep 2020 10:34:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC08F6B0037; Fri, 11 Sep 2020 10:34:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AED96B0055; Fri, 11 Sep 2020 10:34:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0184.hostedemail.com [216.40.44.184]) by kanga.kvack.org (Postfix) with ESMTP id 862AF6B0003 for ; Fri, 11 Sep 2020 10:34:40 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 455DD180AD801 for ; Fri, 11 Sep 2020 14:34:40 +0000 (UTC) X-FDA: 77251026720.27.van31_0703ed5270ef Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 2AAEF3D670 for ; Fri, 11 Sep 2020 14:34:25 +0000 (UTC) X-HE-Tag: van31_0703ed5270ef X-Filterd-Recvd-Size: 4079 Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Sep 2020 14:34:24 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id v23so12676084ljd.1 for ; Fri, 11 Sep 2020 07:34:24 -0700 (PDT) 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; bh=whET1u0frndw3clwDKq4JC8leGkCzgkKJUaCeQP23xM=; b=n2C7UIY2knmo8+BRufNk9Thlmmy4uRmK/KQpQDHmppA0KKqOFLyQ+S3NxlDfzOu38p 7HWNV1aN2GHLM/Cj5Oc/ymjRlgrO5YsJm8WffZeCVmCKKBOowNoTLwwAcqRloJZjhVlY xAB5RXiOgcDxR9QkFXa9wrKpBAg6I8iz5P4xC14NkDtuIhvd7sOwEUAE1VhXFAqLGmkN IfCW1ItgSNtIdq/EbWToXZ0ztv0l2STF59dhmU7Elr69cmqBiyIcXV/G2XtjYNIXohFV JgipY20kbqGMJsgvitQNawbfeTuFJX9KdtSlvAsSnXT1DguhPU+Y16Vzea8FrzzvN67R Q4gA== 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; bh=whET1u0frndw3clwDKq4JC8leGkCzgkKJUaCeQP23xM=; b=rTLqxB6DMF6T+VjDq6VGlnCzAmx2/0vthtNR0mZVNVkdGvYbGo9xWmIup2QmvbBSRM E9+EZW7RdhwgaqkgSaFtmVdCjSu7tZNO253y8S/+xk/hIZ2ghKrmVY1quvnHVYxdW0gV wBfwdn3kJmSm3Vt0lmadlF5SUhydBXBAfSJZ6sral9AksSMVluAfEb2IqnekrP+Q/pJw lArr4Vu5tFhvOTYWr4vmNC2Mn8Km0d2Us01iMovCWhKK50XQ6eAZLiB0pWRDtZVpjBTr 8Bz0U2vH4amueO7SaZygqgFwlqdd6t2D94h7uuqF36nvQvAKU13WGHMz/7XV2vs45TPu PLPQ== X-Gm-Message-State: AOAM530fFiQkzI3cZ4PQHUrqJhlvgj84oyYiFCUxEmxIYv7u5T+wiWWG 1yTLEyCCg3BsHjluPD2W+VW3WQ== X-Google-Smtp-Source: ABdhPJyWGfJWJBr5jiPgGieuOI9lT59w3GB9j84mQrbvvJypivifIVH4xryg2mhLVO8uUqQCOU1B5g== X-Received: by 2002:a05:651c:205b:: with SMTP id t27mr852408ljo.95.1599834863155; Fri, 11 Sep 2020 07:34:23 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id 134sm101476lfd.101.2020.09.11.07.34.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 07:34:21 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 0D7291021C6; Fri, 11 Sep 2020 17:34:28 +0300 (+03) Date: Fri, 11 Sep 2020 17:34:28 +0300 From: "Kirill A. Shutemov" To: "Matthew Wilcox (Oracle)" Cc: Andrew Morton , linux-mm@kvack.org, William Kucharski Subject: Re: [PATCH] mm/filemap: Fix filemap_map_pages for THP Message-ID: <20200911143428.u7v7tr4vhrvye2id@box> References: <20200911012532.24761-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200911012532.24761-1-willy@infradead.org> X-Rspamd-Queue-Id: 2AAEF3D670 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Sep 11, 2020 at 02:25:32AM +0100, Matthew Wilcox (Oracle) wrote: > We dereference page->mapping and page->index directly after calling > find_subpage() and these fields are not valid for tail pages. While > commit 4101196b19d7 introduced the call to find_subpage(), the problem > existed prior to this; I'm going to suggest all the way back to when > THPs first existed. When hugetmpfs made upstream. > The user-visible effects of this are almost negligible. To hit it, you > have to mmap a tmpfs file at an unaligned address and then it's only > a disabled optimisation causing page faults to happen more frequently > than they otherwise would. > > Fix this by keeping both head and page pointers and checking the > appropriate one. We could use page_mapping() and page_to_index(), > but that's higher overhead. > > Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov