Received: by 10.192.165.148 with SMTP id m20csp2112364imm; Thu, 3 May 2018 10:33:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpeQL3W1/XLwLSslK4/m91Bzm6zeGlRJtFQeL1wH3T9zVN3z8FGUt2iJVsVnpYTb/WCJwSU X-Received: by 2002:a63:5c3:: with SMTP id 186-v6mr19699194pgf.218.1525368798915; Thu, 03 May 2018 10:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525368798; cv=none; d=google.com; s=arc-20160816; b=H1kMybaxZpoXgnHJMgDjm/8dYP/Y+Kc+IdqkIg3IoQjqtRKTKvjHRXvSsGV9kqTBne HsO6g3pmvOqXslrvfsJwprZDYPkxUu+3zAI8c66Qn0oLFisl21Mc6oY8/g1yk4RKguOh LOQJOUQYsWe7iMzhUu2HT5Nj4UsjTkDi3Jma7hyCgmFEGDj85UB/N8v10bVQsUgIYZJC 6EabENIKYudywHtAMzF+N1Wt5JaCq0Cl5bFP//HqaYyeHrFWpUGy9Pggd8tj6zuGYCux WIAgKIoSd74T7+O2/YuQjHD6Z9RZrpGnCvU90SvLsDPjW1SracPbx9vLo0Y/IaycXfl6 36fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=0JeQ6X7TwFANZvinrBacHhnXVeAT34u+VXmT7eSRR2E=; b=cu9zUQffeG2d+lWsDgDSS+YUYNPtG2/kf0jfXDvXWgBHZtfwvaAlTPb965d2mtJCHi raSeF556pkCPJzGvPxSm6iQUhIvo1hToxPXKhUmoIvNq/IJi6gkEllUkLp9m7CI+ir37 BkJH9RGWB1qFY9gd/9XHaolPOOIHVAMrAZqtPBmfbVeRPOM4ZqFP4p4UCc52cYCRV/Kc 3yMldPuqTFZ1j8Z1ZmsQKKjt5C+c5ddaJL+9J05iKHeIJXtKhhKmjieWX+hJ3BaTxxq2 ckXPp5T1A8d6ahyyGjrnhMMkfmyGAaSat4vq5mrfY/XXyIjcTMoRgm53x90iERVfIf/h euIw== 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 o5-v6si3010463pgd.194.2018.05.03.10.33.04; Thu, 03 May 2018 10:33:18 -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 S1751393AbeECRcT (ORCPT + 99 others); Thu, 3 May 2018 13:32:19 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44534 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751095AbeECRcO (ORCPT ); Thu, 3 May 2018 13:32:14 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62947406C783; Thu, 3 May 2018 17:32:13 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E215383B79; Thu, 3 May 2018 17:32:08 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w43HW8GH030334; Thu, 3 May 2018 13:32:08 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w43HW8JX030330; Thu, 3 May 2018 13:32:08 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Thu, 3 May 2018 13:32:08 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Andrew Morton cc: Michal Hocko , Matthew Wilcox , David Miller , linux-mm@kvack.org, eric.dumazet@gmail.com, edumazet@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, dm-devel@redhat.com, Vlastimil Babka Subject: Re: [PATCH] kvmalloc: always use vmalloc if CONFIG_DEBUG_VM In-Reply-To: <20180501173626.4593a87d0d64f6cc9d219d20@linux-foundation.org> Message-ID: References: <20180420130852.GC16083@dhcp22.suse.cz> <20180420210200.GH10788@bombadil.infradead.org> <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> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 03 May 2018 17:32:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 03 May 2018 17:32:13 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mpatocka@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 1 May 2018, 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? > > 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). Yes, it would be good. You also need to check it in virt_to_phys(), virt_to_pfn(), __pa() and maybe some others. Mikulas