Received: by 10.192.165.148 with SMTP id m20csp155922imm; Fri, 20 Apr 2018 04:48:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/2q6KKwpNLaWKnpfzMX4KznEQoDP+PIlBt9cEoZ9yaG10J2HR8paZZKexbhVQvRJZUyRk1 X-Received: by 2002:a17:902:2804:: with SMTP id e4-v6mr7870045plb.153.1524224923836; Fri, 20 Apr 2018 04:48:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524224923; cv=none; d=google.com; s=arc-20160816; b=zmSr++Y63ko/dmH0U420rN+bX9DFjBnAzp8WuwNESgQKCn0e6t3c7bYfwXMyLQHEjd 9HW0Q2QJMlILze6gHEa7oFTQ5jBGKdQURK7yk/d6Qbo6Ki9/w39PeDUA8wFPZcbHa8Et dVXtHsy0bf+SOpyQJCNThtsDFOTAB7YAH7xnsjz7zq9fjfHQOck45Qry2zCb/T2gG4Z/ lfhCsIg2L5V4lKwFM3lCDkgwCiaU1LPFeJlRavhCOzhaHaELIYNwceYnCasIcCIE/A/5 WKb+Z8i8NZoYeKCtx+u8trxY7z/3HLJCT/Kb39xhZndoLZ5S/tdiwsdbyb0y/rJceDug fBaQ== 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:arc-authentication-results; bh=W0KODHkhCdycVYTXtkWH5dy+MT56zLaFHVo/QbwRboE=; b=kNc28mY+XA0PWC+e3gtnzgHezsNRlVq8rQ0S3qBxVzfRK0bs/qN6c5Bhvrdf1psNwO vhp0eHDLJhbeyrfPZ9DWemICG8w+JAYKHkLTiJSLWaSRw+4RLwdjja+zoaK6FFGgucho ez1jx7vtf9BeDAg2e++F7Z7H7eR6bkzqRYq0/LMKavNhv/VMajFybNnDVmF0HPnUhKm6 0xpKgAPR6dfD7PRxiCNOmUIGmFhESMMTzEuBCXZewPPebEjlrqbqO6eNKMWZdKNgtwuT 34VIL7rwmIToCf7NvsDlFziX9pjR/6LNPNiLAVD6GxldHxcp2xh8miuSltyfQsghoTy9 G8jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ep/5RNIW; 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 a1si4743553pgq.594.2018.04.20.04.48.28; Fri, 20 Apr 2018 04:48:43 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ep/5RNIW; 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 S1754703AbeDTLrU (ORCPT + 99 others); Fri, 20 Apr 2018 07:47:20 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:40258 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754591AbeDTLrS (ORCPT ); Fri, 20 Apr 2018 07:47:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=W0KODHkhCdycVYTXtkWH5dy+MT56zLaFHVo/QbwRboE=; b=ep/5RNIWVvvA5/x3+ohriGe1+ Y9pTasr+JXn+a70G3xe/2kgfD7hdAn29J5ItxsQDLwwkvYaxWCMlP389Gk7pJr4GptYkYSE6lBjjU 7wAYZIe1MjDTqB6cnb3UUu8Y+MTmpiGZdwvHlVe4CqOggBmkjxXNexTG2DYyYHtdeTjxrlyqN2lxs zAr+ZpeZSuvSi2C3IwxZWxOXJpMSTiV6p8c8Qtr7oMmCF7Dh7BQ7rygZcwox5W+95dscDVkFoPEM5 A+T0EZvNpjEbwB8vaNCNdD623oTAFZvGpRISL9YK5xfLl/V8deYPRit0T8ci+qdtE9nOj+fEsMqby IDbO4OLyw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9UVV-0004kz-5M; Fri, 20 Apr 2018 11:47:13 +0000 Date: Fri, 20 Apr 2018 04:47:12 -0700 From: Matthew Wilcox To: Mikulas Patocka Cc: David Miller , Andrew Morton , 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 Message-ID: <20180420114712.GB10788@bombadil.infradead.org> References: <3e65977e-53cd-bf09-bc4b-0ce40e9091fe@gmail.com> <20180418.134651.2225112489265654270.davem@davemloft.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 19, 2018 at 12:12:38PM -0400, Mikulas Patocka wrote: > Unfortunatelly, some kernel code has bugs - it uses kvmalloc and then > uses DMA-API on the returned memory or frees it with kfree. Such bugs were > found in the virtio-net driver, dm-integrity or RHEL7 powerpc-specific > code. Maybe it's time to have the SG code handle vmalloced pages? This is becoming more and more common with vmapped stacks (and some of our workarounds are hideous -- allocate 4 bytes with kmalloc because we can't DMA onto the stack any more?). We already have a few places which do handle sgs of vmalloced addresses, such as the nx crypto driver: if (is_vmalloc_addr(start_addr)) sg_addr = page_to_phys(vmalloc_to_page(start_addr)) + offset_in_page(sg_addr); else sg_addr = __pa(sg_addr); and videobuf: pg = vmalloc_to_page(virt); if (NULL == pg) goto err; BUG_ON(page_to_pfn(pg) >= (1 << (32 - PAGE_SHIFT))); sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); Yes, there's the potential that we have to produce two SG entries for a virtually contiguous region if it crosses a page boundary, and our APIs aren't set up right to make it happen. But this is something we should consider fixing ... otherwise we'll end up with dozens of driver hacks. The videobuf implementation was already copy-and-pasted into the saa7146 driver, for example.