Received: by 10.192.165.148 with SMTP id m20csp187192imm; Fri, 20 Apr 2018 05:18:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx48FKnyTCV00seNbeIzI0fJ1wcbtPJhdlGJVIf7atuytiuppL1f+DjX1MEmX9z/xLAs0RWnC X-Received: by 10.99.54.136 with SMTP id d130mr3916981pga.228.1524226721057; Fri, 20 Apr 2018 05:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524226721; cv=none; d=google.com; s=arc-20160816; b=ARyf2A7BjG0V6L/Y+UOJu5bUItlg3K81hvASh8Gt91VJLZN0jcODyXype28V4MF16B mIxtxWeZZeRr5MHk1ep7+ekcjf/O363S/2Qo9uB5bvqobI/fkt7eupw7XoIGJDFbaD8c YLOBlrPjc9CDDwuKW+z6qvHvRiGxg6kxThHeOGsHbbgDwxjBsq7WO/h6O8/bkRIAzMOJ bYChRfDtwUMq2YxdP776gI3pqRR7STxMb+Ainxwy+RzCqbb+RDP4Xj1sJlCQku13+XYS CS8LOxWM6x/TJY9jGm2V4bigCK71TmSz1zTkX74aYA6mpp8KhqWK/9PapL/2UOLmUpA9 kzTQ== 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=jEWdhYku3rO1YDuqU87tONbtHKiwlQbQDb/+ciY79MM=; b=Q1FSMkDImg7jgiP6dRxJreSbQ6o4r0EFlDhz00rU/qsGYOb9JKIOBDu1Kkq64Zr5WD W5TtRNEufhdbEw0ekGJqgfv3ulrGne5lVMwVZUNBpJD6phLoj63Im/NNXiheAAgMJDmk kWRIib7LfIWu7tKYpK/aDPKrl1cLUFQgQvQ7A9XAsIjZcgT/mkgs70hoDzOIQcs9IA4q M0CTRF4u0b0YITdbPXYG1h5HBGdERRh7mIUCwlScIhgN/v4Q+F+Qpp3EKN8PPHvRPmuK CyJqvNBuGIGnOm1YZBlKOxIijXl71x2GeaKHxAjYk5cybaJCEpJBvUUVa6jmFnHppIJq cAeg== 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 a7si4854512pgd.690.2018.04.20.05.18.26; Fri, 20 Apr 2018 05:18:41 -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 S1754819AbeDTMQ7 (ORCPT + 99 others); Fri, 20 Apr 2018 08:16:59 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42608 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754686AbeDTMQ6 (ORCPT ); Fri, 20 Apr 2018 08:16:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B63F402314E; Fri, 20 Apr 2018 12:16:57 +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 C8A801102E24; Fri, 20 Apr 2018 12:16:52 +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 w3KCGqoN026904; Fri, 20 Apr 2018 08:16:52 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w3KCGqJu026898; Fri, 20 Apr 2018 08:16:52 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Fri, 20 Apr 2018 08:16:52 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Andrew Morton cc: David Miller , linux-mm@kvack.org, eric.dumazet@gmail.com, edumazet@google.com, bhutchings@solarflare.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: <20180419162250.00bf82e2c40b4960a7e23cdc@linux-foundation.org> Message-ID: References: <3e65977e-53cd-bf09-bc4b-0ce40e9091fe@gmail.com> <20180418.134651.2225112489265654270.davem@davemloft.net> <20180419124751.8884e516e99825d83da3d87a@linux-foundation.org> <20180419162250.00bf82e2c40b4960a7e23cdc@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.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 20 Apr 2018 12:16:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 20 Apr 2018 12:16:57 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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 Thu, 19 Apr 2018, Andrew Morton wrote: > On Thu, 19 Apr 2018 17:19:20 -0400 (EDT) Mikulas Patocka wrote: > > > > > In order to detect these bugs reliably I submit this patch that changes > > > > kvmalloc to always use vmalloc if CONFIG_DEBUG_VM is turned on. > > > > > > > > ... > > > > > > > > --- linux-2.6.orig/mm/util.c 2018-04-18 15:46:23.000000000 +0200 > > > > +++ linux-2.6/mm/util.c 2018-04-18 16:00:43.000000000 +0200 > > > > @@ -395,6 +395,7 @@ EXPORT_SYMBOL(vm_mmap); > > > > */ > > > > void *kvmalloc_node(size_t size, gfp_t flags, int node) > > > > { > > > > +#ifndef CONFIG_DEBUG_VM > > > > gfp_t kmalloc_flags = flags; > > > > void *ret; > > > > > > > > @@ -426,6 +427,7 @@ void *kvmalloc_node(size_t size, gfp_t f > > > > */ > > > > if (ret || size <= PAGE_SIZE) > > > > return ret; > > > > +#endif > > > > > > > > return __vmalloc_node_flags_caller(size, node, flags, > > > > __builtin_return_address(0)); > > > > > > Well, it doesn't have to be done at compile-time, does it? We could > > > add a knob (in debugfs, presumably) which enables this at runtime. > > > That's far more user-friendly. > > > > But who will turn it on in debugfs? > > But who will turn it on in Kconfig? Just a handful of developers. We So, it won't receive much testing. I've never played with those debugfs files (because I didn't need it), and most users also won't play with it. Having a debugfs option is like having no option at all. > could add SONFIG_DEBUG_SG to the list in > Documentation/process/submit-checklist.rst, but nobody reads that. > > Also, a whole bunch of defconfigs set CONFIG_DEBUG_SG=y and some > googling indicates that they aren't the only ones... > > > It should be default for debugging > > kernels, so that users using them would report the error. > > Well. This isn't the first time we've wanted to enable expensive (or > noisy) debugging things in debug kernels, by any means. > > So how could we define a debug kernel in which it's OK to enable such > things? Debug kernel is what distributions distribute as debug kernel - i.e. RHEL or Fedora have debugging kernels. So it needs to be bound to an option that is turned on in these kernels - so that any user who boots the debugging kernel triggers the bug. > - Could be "it's an -rc kernel". But then we'd be enabling a bunch of > untested code when Linus cuts a release. > > - Could be "it's an -rc kernel with SUBLEVEL <= 5". But then we risk > unexpected things happening when Linux cuts -rc6, which still isn't > good. > > - How about "it's an -rc kernel with odd-numbered SUBLEVEL and > SUBLEVEL <= 5". That way everybody who runs -rc1, -rc3 and -rc5 will > have kvmalloc debugging enabled. That's potentially nasty because > vmalloc is much slower than kmalloc. But kvmalloc() is only used for > large and probably infrequent allocations, so it's probably OK. > > I wonder how we get at SUBLEVEL from within .c. Don't bind it to rc level, bind it to some debugging configuration option. Mikulas