Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4079096imm; Mon, 20 Aug 2018 09:26:20 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzGu/0ALVoALRJxQ3AVhx0J4wXzzZ+E6FxMkVcjU/GOfBVCezUgwHYMkxFK1ywc3H9mFN4E X-Received: by 2002:a63:6988:: with SMTP id e130-v6mr4424784pgc.249.1534782380877; Mon, 20 Aug 2018 09:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534782380; cv=none; d=google.com; s=arc-20160816; b=ZRsdzmgIWHkpYrOurmcdffQgdG0nJnuiuat/3JePYYySmuY5yY+1F0i6mBjXNT5DiI h7a4s91L+is1LTfQ20Lw+ivp5dbIHpKCtVBIw7dDeQzuUALPhrmOBzOucFpo9S6OaRBF EcqT1ps8iO7APGIwKt2kFizrQjCtWTR2QsSAsGEFfnVWXCqsmzCt1TlrLQHXPCpe8fRt azSo4DLAbQMwPMTDMsyuUpuftCG12DzBBFPIABkfIg7OZrXZIE/iOCSpQyPW+lUuvb/W VLDBbe23zj6XxijxKPsWIlDk9o0PVjSYhhAIXclhMnBAIU+QvuUyo65/XtamynhHEVXS uwew== 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=DVAmQUA2m3LYYIRD8YdZ2JZnxuuksbNYh0EGHnvOH8Q=; b=cu2RZHhcHmaJFv9DEpnZLThNntOoQy+eZUtZ3N+0aT1I53wcAohaUBEETU9MTtMe4S gcbOpmyhm2TQuyXOEUQXqTeixzat5j9ZVeFkwv6uC4XInpqXfuY1ERj67rBHCa501yO0 HU7y97NotaIM5fcQYKsn1BR4VQ9Nrqh27AP4Gtx+sz0yjtylKmMuxwmfc2RyFJbOdi14 357UO8OKB3/6aQG3+2EthIyzSeTDLhc1scSI9jA/YtYFqZP4mjnA+7n2jQ/Mcixm+V1J CPyTHDMxnBPrSmyNF9XQ5ydrm2Q0QirgEfBpArbGsXbJcBBMkjKbdq3SUiBHVpmN8RlX ctrw== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z188-v6si10947332pfb.26.2018.08.20.09.26.05; Mon, 20 Aug 2018 09:26:20 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727516AbeHTTk1 (ORCPT + 99 others); Mon, 20 Aug 2018 15:40:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:38846 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726596AbeHTTk1 (ORCPT ); Mon, 20 Aug 2018 15:40:27 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CE8B1AFEB; Mon, 20 Aug 2018 16:24:07 +0000 (UTC) Date: Mon, 20 Aug 2018 18:24:06 +0200 From: Michal Hocko To: Matthew Wilcox Cc: Li RongQing , Andrew Morton , Dan Williams , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, "Kirill A. Shutemov" , Matthew Wilcox , Souptick Joarder , darrick.wong@oracle.com Subject: Re: [PATCH] mm: introduce kvvirt_to_page() helper Message-ID: <20180820162406.GQ29735@dhcp22.suse.cz> References: <1534596541-31393-1-git-send-email-lirongqing@baidu.com> <20180820144116.GO29735@dhcp22.suse.cz> <20180820144923.GA25153@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180820144923.GA25153@bombadil.infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 20-08-18 07:49:23, Matthew Wilcox wrote: > On Mon, Aug 20, 2018 at 04:41:16PM +0200, Michal Hocko wrote: > > On Sat 18-08-18 20:49:01, Li RongQing wrote: > > > The new helper returns address mapping page, which has several users > > > in individual subsystem, like mem_to_page in xfs_buf.c and pgv_to_page > > > in af_packet.c, unify them > > > > kvvirt_to_page is a weird name. I guess you wanted it to fit into > > kv*alloc, kvfree naming, right? If yes then I guess kvmem_to_page > > would be slightly better. > > > > Other than that the patch makes sense to me. It would be great to add > > some documentation and be explicit that the call is only safe on > > directly mapped kernel address and vmalloc areas. > > ... and not safe if the length crosses a page boundary. I don't want to > see new code emerge that does kvmalloc(PAGE_SIZE * 2, ...); kvmem_to_page() > and have it randomly crash when kvmalloc happens to fall back to vmalloc() > under heavy memory pressure. > > Also, people are going to start using this for stack addresses. Perhaps > we should have a debug option to guard against them doing that. I do agree that such an interface is quite dangerous. That's why I was stressing out the proper documentation. I would be much happier if we could do without it altogether. Maybe the existing users can be rewoked to not rely on the addr2page functionality. If that is not the case then we should probably offer a helper. With some WARN_ONs to catch misuse would be really nice. I am not really sure how many abuses can we catch actually though. -- Michal Hocko SUSE Labs