From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752052AbbCWA26 (ORCPT ); Sun, 22 Mar 2015 20:28:58 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:33151 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751939AbbCWA24 (ORCPT ); Sun, 22 Mar 2015 20:28:56 -0400 Date: Sun, 22 Mar 2015 17:28:47 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: "Kirill A. Shutemov" cc: Andrew Morton , Andrea Arcangeli , Hugh Dickins , Dave Hansen , Mel Gorman , Rik van Riel , Vlastimil Babka , Christoph Lameter , Naoya Horiguchi , Steve Capper , "Aneesh Kumar K.V" , Johannes Weiner , Michal Hocko , Jerome Marchand , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 00/16] Sanitize usage of ->flags and ->mapping for tail pages In-Reply-To: <1426784902-125149-1-git-send-email-kirill.shutemov@linux.intel.com> Message-ID: References: <1426784902-125149-1-git-send-email-kirill.shutemov@linux.intel.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Mar 2015, Kirill A. Shutemov wrote: > Currently we take naive approach to page flags on compound -- we set the > flag on the page without consideration if the flag makes sense for tail > page or for compound page in general. This patchset try to sort this out > by defining per-flag policy on what need to be done if page-flag helper > operate on compound page. > > The last patch in patchset also sanitize usege of page->mapping for tail > pages. We don't define meaning of page->mapping for tail pages. Currently > it's always NULL, which can be inconsistent with head page and potentially > lead to problems. > > For now I catched one case of illigal usage of page flags or ->mapping: > sound subsystem allocates pages with __GFP_COMP and maps them with PTEs. > It leads to setting dirty bit on tail pages and access to tail_page's > ->mapping. I don't see any bad behaviour caused by this, but worth fixing > anyway. But there's nothing to fix there. We're more used to having page->mapping set by filesystems, but it is normal for drivers to have pages with NULL page->mapping mapped into userspace (and it's not accidental that they appear !PageAnon); and subpages of compound pages mapped into userspace, and set_page_dirty applied to them. > > This patchset makes more sense if you take my THP refcounting into > account: we will see more compound pages mapped with PTEs and we need to > define behaviour of flags on compound pages to avoid bugs. Yes, I quite understand that you want to clarify the usage of different page flags to yourself, to help towards a policy of what to do with each of them when subpages of a huge compound page are mapped into userspace; but I don't see that we need this patchset in the kernel now, given that it adds unnecessary overhead into several low-level inline functions. I'm surprised that Andrew has fast-tracked it into his mmotm tree: I don't think it's harmful beyond the overhead, but it seems premature: let's wait until we get some benefit too? Hugh