Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3093338ybt; Mon, 22 Jun 2020 14:59:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrOIxUXYgL3vh9LjagDFP3bsOG/JEmp9zcDz4DlaH+2AbJe5JlgPToBqZc0SkW9g4bG0KM X-Received: by 2002:a50:b0a1:: with SMTP id j30mr19197648edd.387.1592863173123; Mon, 22 Jun 2020 14:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592863173; cv=none; d=google.com; s=arc-20160816; b=Fl6Qlm2q3TKgikT2HKiMU7bxJ3DVMDtdh3waYjvjjoXYuX2H3bKcRejVciWjAHUf5X KWzN2NJsUlG/sE4+JS/GBbhYHs/K0Eg0Ka4MwLp32XZuxp0N9VsuONkHSFWBO9RrNA6J 4v4RJVWFis7h7Zrz74So36lPejHWBT9f4iYPsFcbLYjUimQMPUhTOj6WgxfvvvlQymRd 7ARfIee4ymJnvk7/dXug3DMF+KxbzNR47SOiBVCPIYOfEC0HJIEHTjMQ827gXF1qf/eT OzXI9P87JJD8JhX9MS1h1bcmD7xEZuq8EaEpKakzqLNQiv+gpCHB84Te2RmY1imkkW+L PHCA== 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=uMbPsqGUvOKb001hQipRcEAVs1+07nW6ycVZC/UvqlI=; b=iOVIaZA+lxpA63DtL5pV3l2f8J6jHmLjUcEPOpkjezi8UMrYh1kctt32u7ZTmyzUJY xYRixTfueU9vwg/PZbn3uc+FnZY6ggqJmKqM2OAv4WjZTKhAgesk33rMPDDgSxLQjixq LJeJNkhMpw8rdU2ZiQtUrJ/WI9ZSrDQLLZ0jN1OpOFxpv4EJczykCLMV5RH05uYEuynd nDJxzkHfgHgITXswFt6W7Q1triWHyguKblih3/16DSsQroN9t9ktQNiJnKukzvmrBhPm C8NU1ciz0UOaONa8EflChV7MgV/9WgOfjCYlBhY0lqNK04Coo2NCFoG/OvmgzS5KBJfa Il2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fz7Kv1Cj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc15si10724101edb.281.2020.06.22.14.59.10; Mon, 22 Jun 2020 14:59:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fz7Kv1Cj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730721AbgFVV5I (ORCPT + 99 others); Mon, 22 Jun 2020 17:57:08 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:33477 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730576AbgFVV5I (ORCPT ); Mon, 22 Jun 2020 17:57:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592863026; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=uMbPsqGUvOKb001hQipRcEAVs1+07nW6ycVZC/UvqlI=; b=fz7Kv1CjoiaPMNbJ+KExNNKkk22EEd2lGZQnOCWW6cOIleTZ4VQqEVgpDyZymzh9DJEi5u QhlORtsdICb5sT1hGgAsJAYcaz3nnaG8ezCt5oaCZSOH9uzwmH+Q6orhopzXcoSigpWu+f NRYGHtX444jNdDO8g9Jb5aoxSuPMpbg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-488-zgop9R65Nc-KYu6Pt_FCgw-1; Mon, 22 Jun 2020 17:57:02 -0400 X-MC-Unique: zgop9R65Nc-KYu6Pt_FCgw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 557691883608; Mon, 22 Jun 2020 21:57:00 +0000 (UTC) Received: from mail (ovpn-112-10.rdu2.redhat.com [10.10.112.10]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B76D410013D2; Mon, 22 Jun 2020 21:56:59 +0000 (UTC) Date: Mon, 22 Jun 2020 17:56:58 -0400 From: Andrea Arcangeli To: Robin Murphy Cc: Joerg Roedel , Roman Gushchin , Yang Shi , iommu@lists.linux-foundation.org, Linux Kernel Mailing List , Linux MM , Michal Hocko , Johannes Weiner , "Kirill A. Shutemov" , Andrew Morton , Wei Yang , Will Deacon Subject: Re: kernel BUG at mm/huge_memory.c:2613! Message-ID: <20200622215658.GC12414@redhat.com> References: <20200619001938.GA135965@carbon.dhcp.thefacebook.com> <20200619011449.GC135965@carbon.dhcp.thefacebook.com> <20200619024026.GB21081@redhat.com> <20200622124646.GI3701@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.14.2 (2020-05-25) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Mon, Jun 22, 2020 at 04:30:41PM +0100, Robin Murphy wrote: > On 2020-06-22 13:46, Joerg Roedel wrote: > > + Robin > > > > Robin, any idea on this? > > After a bit of archaeology, this dates back to the original review: > > https://lore.kernel.org/linux-arm-kernel/54C285D4.3070802@arm.com/ > https://lore.kernel.org/linux-arm-kernel/54DA2666.9030003@arm.com/ > > In summary: originally this inherited from other arch code that did > simply strip __GFP_COMP; that was deemed questionable because of the > nonsensical comment about CONFIG_HUGETLBFS that was stuck to it; the > current code is like it is because in 5 and a half years nobody said > that it's wrong :) > > If there actually *are* good reasons for stripping __GFP_COMP, then I've > certainly no objection to doing so. The main question is if there's any good reasons for not forbidding __GFP_COMP to be specified in the callers. The reason given in the comment isn't convincing. I don't see how a caller that gets a pointer can care about how the page structure looks like and in turn why it's asking for __GFP_COMP. As far as I can tell there are two orthogonal issues in play here: 1) The comment about __GFP_COMP facilitating the sound driver to do partial mapping doesn't make much sense. It's probably best to WARN_ON immediately in dma_alloc_coherent if __GFP_COMP is specified, not only down the call stack in the __iommu_dma_alloc_pages() path. Note: the CMA paths would already ignore __GFP_COMP if it's specified so that __GFP_COMP request can already be ignored. It sounds preferable to warn the caller it's asking something it can't get, than to silently ignore __GFP_COMP. On a side note: hugetlbfs/THP pages can only be allocated with __GFP_COMP because for example put_page() must work on all tail pages (you can't call compound_head() unless the tail page is part of a compound page). But for private driver pages mapped by remap_pfn_range, any full or partial mapping is done manually and nobody can call GUP on VM_PFNMAP|VM_IO anyway (there's not even the requirement of a page struct backing those mappings in fact). 2) __iommu_dma_alloc_pages cannot use __GFP_COMP if it intends to return an array of small pages, which is the only thing that the current sg_alloc_table_from_pages() supports in input. split_page will work as expected to generate small pages from non-compound order>0 pages, incidentally it's implement on mm/page_alloc.c, not in huge_memory.c. split_huge_page as opposed is not intended to be used on newly allocated compound page. Maybe we should renamed it to split_trans_huge_page to make it more explicit, since it won't even work on hugetlbfs (compound) pages. Thanks, Andrea