Received: by 10.192.165.148 with SMTP id m20csp650045imm; Wed, 2 May 2018 06:41:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoRKEf5FDWbfWj+MvNjz/IKoBjfQkqnkR9LzGTJQUZa8E+DtVil/2kImQgCU68lbsyTcgPu X-Received: by 2002:a17:902:5382:: with SMTP id c2-v6mr20313397pli.335.1525268482570; Wed, 02 May 2018 06:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525268482; cv=none; d=google.com; s=arc-20160816; b=DSouarIt7FkgSKv7Eqxmvuwy2HoEaFGLFfjM1vHQAT0AylqyRPxgcBm55J/kKA9Fqh gtUAp5Pxd45fiK9mDag3qo0T1lVadwUs9y3C1xXNPR1SUPpblYLLOFrWO5LogKRGdZ/F y9l7e3Eizhn6tauFaBbAsJz8ftASMDiorGEJMdpmYMmY0u1GuPwnOzPg5TM69+MfC4m2 4uerXNjRowT5FBuI7w4t5Y3ZXpzWccAmVwUt1veRSz1xap/Qbw6OibUmdtGBHrma6pVu 5eTP6yZX/IEJq00ZYP1GsRtYuFHFhuGaMbRX31nXrPPDOG+/eOyyREqlACpVJmqjk44w vyNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:subject:cc:to:from :date:message-id:content-transfer-encoding:mime-version :arc-authentication-results; bh=j/FNLpByqvHn0u2ytTkF+USQMfuOClfbVJBqOVSpEtk=; b=PX393hWk8Z+sdIsjebwpklresBOEjmAkGwRxmzXT/yF4rPOa7dwB6A0ElNMlkz5Rzq F2WtZ/Brf+alpfaz0Ol6jcHKZACSL3DoBQs0cZxNfjtcC4XxiQXLvru/o5jaa695xI55 BgUVkWp83SZ7Qh0eaytwbTSyjtiUdkx9WN8SJekAlGI9oexF77r6Ny619nAxJvBUUEl1 mcZSt5jgMGfP6wr8DznJN2eBvZhX3e6CIbYJBv48TdS3w1mdlMUkjIkJ6ruofsbqa3Lo GADHj8x14n/mZTwGe6+hbL0/SwZSPCvu7DUuL0LSJf4cobkq5NaXU8hgTNSEMfHMGqMG GadQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7si10185666pfa.78.2018.05.02.06.41.08; Wed, 02 May 2018 06:41:22 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751411AbeEBNko (ORCPT + 99 others); Wed, 2 May 2018 09:40:44 -0400 Received: from mail.stoffel.org ([104.236.43.127]:40614 "EHLO mail.stoffel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbeEBNki (ORCPT ); Wed, 2 May 2018 09:40:38 -0400 Received: from quad.stoffel.org (66-189-75-104.dhcp.oxfr.ma.charter.com [66.189.75.104]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.stoffel.org (Postfix) with ESMTPSA id 93C595FD9C; Wed, 2 May 2018 09:40:37 -0400 (EDT) Received: by quad.stoffel.org (Postfix, from userid 1000) id 0A1DEA2D38; Wed, 2 May 2018 09:40:27 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <23273.49098.982175.973732@quad.stoffel.home> Date: Wed, 2 May 2018 09:40:26 -0400 From: "John Stoffel" To: Mike Snitzer Cc: Andrew Morton , 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, dm-devel@redhat.com, Mikulas Patocka , Babka , virtualization@lists.linux-foundation.org, David Miller , edumazet@google.com Subject: Re: [dm-devel] kvmalloc: always use vmalloc if CONFIG_DEBUG_VM In-Reply-To: <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> <20180502133224.GA22123@redhat.com> X-Mailer: VM 8.2.0b under 24.5.1 (x86_64-pc-linux-gnu) X-Clacks-Overhead: GNU Terry Pratchett Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>>>> "Mike" == Mike Snitzer writes: Mike> On Tue, May 01 2018 at 8:36pm -0400, Mike> 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? Mike> 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). Mike> Thanks Andrew, definitely the most sane proposal I've seen to resolve Mike> this. Cuts to the heart of the issue I think, and seems pretty sane. Should the WARN be rate limited as well? John