Received: by 10.192.165.148 with SMTP id m20csp643138imm; Wed, 2 May 2018 06:34:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqbuP8DuVFtkVTP8l/7V/ki8IKCk/K9NMm+NUXJLtcTpM3slgyH4uyOzt8YJkMaqCzF+isT X-Received: by 2002:a17:902:ba87:: with SMTP id k7-v6mr12069549pls.193.1525268067901; Wed, 02 May 2018 06:34:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525268067; cv=none; d=google.com; s=arc-20160816; b=lkKhcIiNb6Mwqj3KgilVKvpfFzuPh/A8A3m2Awu1PdIX5mMgRx4S/j5rOWbKlbzx4Z I0LxoyYNfCheXejcxO3rL/Npe/iuiJ/uA0MGj8HIdtn90ZbR4a0jluBfPdJCaQG6nLVR Y/efGagyVjnAcWhjatZDTaf/pxCP9wfqePm5VRYSA91BmvD4/3qP4HnjWTGwEgEzbdu9 dRfiKrwbV5cbOoWa8ovOcnFIyTnYMqIAaL1nsFXu7OlOnTWcLcfUV5nNgaIq71WUAhi4 zbsmvxZo3z5Ngd8IxBTv3sPVu/IhqS58SycNCXGVf0t6rHxN7ctJ1RDnPmahYfWbkent QD9w== 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:arc-authentication-results; bh=QHNVUksiZDuy/WaPFYqhmIigWvqA3OYE9a245zKIWpc=; b=wXPByaND8CEClDA0axr/itS2VpzWDk5m1Ly0UDCBaHNhqTHOmO5i9Mf2P/VJjseHWQ FTwnUVXFYDB+ZM0NwTo8qcy3wujJXxyP61q5kCP81VtOvRzzCHscCxyJVIgpYrvnPDzL 1ntLmbhKG65cnTAKYq8dKnGGZB1JyAS2Q7zBxdAYb5NL1Jt0W4qbzTdJy4Vui9fc6SUq QkKI+EKD1r3AlKT/d+wIMkekXzX7OnYmDEiufvZ249x7DJMuK4Kwan/5Uw1M0upKAkou sCDce+6OMg6Iy3ixKuk/4Jfb9A2py/3E1rDQ7n74Jg942cTfvHtrexHc1h3TtzUDG1N3 Nonw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q3-v6si10947955pll.126.2018.05.02.06.34.13; Wed, 02 May 2018 06:34:27 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751579AbeEBNdG (ORCPT + 99 others); Wed, 2 May 2018 09:33:06 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53262 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751570AbeEBNdC (ORCPT ); Wed, 2 May 2018 09:33:02 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4571B81AFEEC; Wed, 2 May 2018 13:33:02 +0000 (UTC) Received: from localhost (unknown [10.18.25.149]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D14B2166BAD; Wed, 2 May 2018 13:33:02 +0000 (UTC) Date: Wed, 2 May 2018 09:33:01 -0400 From: Mike Snitzer To: Andrew Morton Cc: Mikulas Patocka , dm-devel@redhat.com, eric.dumazet@gmail.com, mst@redhat.com, netdev@vger.kernel.org, jasowang@redhat.com, linux-kernel@vger.kernel.org, Matthew Wilcox , Michal Hocko , linux-mm@kvack.org, edumazet@google.com, Babka , virtualization@lists.linux-foundation.org, David Miller Subject: Re: kvmalloc: always use vmalloc if CONFIG_DEBUG_VM Message-ID: <20180502133224.GA22123@redhat.com> References: <20180421144757.GC14610@bombadil.infradead.org> <20180423151545.GU17484@dhcp22.suse.cz> <20180424133146.GG17484@dhcp22.suse.cz> <20180424161242.GK17484@dhcp22.suse.cz> <20180501173626.4593a87d0d64f6cc9d219d20@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180501173626.4593a87d0d64f6cc9d219d20@linux-foundation.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 02 May 2018 13:33:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 02 May 2018 13:33:02 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'msnitzer@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 01 2018 at 8:36pm -0400, Andrew Morton wrote: > On Tue, 24 Apr 2018 12:33:01 -0400 (EDT) Mikulas Patocka wrote: > > > > > > > On Tue, 24 Apr 2018, Michal Hocko wrote: > > > > > On Tue 24-04-18 11:30:40, Mikulas Patocka wrote: > > > > > > > > > > > > On Tue, 24 Apr 2018, Michal Hocko wrote: > > > > > > > > > On Mon 23-04-18 20:25:15, Mikulas Patocka wrote: > > > > > > > > > > > Fixing __vmalloc code > > > > > > is easy and it doesn't require cooperation with maintainers. > > > > > > > > > > But it is a hack against the intention of the scope api. > > > > > > > > It is not! > > > > > > This discussion simply doesn't make much sense it seems. The scope API > > > is to document the scope of the reclaim recursion critical section. That > > > certainly is not a utility function like vmalloc. > > > > That 15-line __vmalloc bugfix doesn't prevent you (or any other kernel > > developer) from converting the code to the scope API. You make nonsensical > > excuses. > > > > Fun thread! > > Winding back to the original problem, I'd state it as > > - Caller uses kvmalloc() but passes the address into vmalloc-naive > DMA API and > > - Caller uses kvmalloc() but passes the address into kfree() > > Yes? I think so. > If so, then... > > Is there a way in which, in the kvmalloc-called-kmalloc path, we can > tag the slab-allocated memory with a "this memory was allocated with > kvmalloc()" flag? I *think* there's extra per-object storage available > with suitable slab/slub debugging options? Perhaps we could steal one > bit from the redzone, dunno. > > If so then we can > > a) set that flag in kvmalloc() if the kmalloc() call succeeded > > b) check for that flag in the DMA code, WARN if it is set. > > c) in kvfree(), clear that flag before calling kfree() > > d) in kfree(), check for that flag and go WARN() if set. > > So both potential bugs are detected all the time, dependent upon > CONFIG_SLUB_DEBUG (and perhaps other slub config options). Thanks Andrew, definitely the most sane proposal I've seen to resolve this.