Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4571753imm; Tue, 9 Oct 2018 01:31:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV613x1om9PZDV9GuxZFR2swR5Mp4gKnOgPXVQKTUc3Y/eTyWL1d4vn2QKGKy/j2KyaSEy79/ X-Received: by 2002:a17:902:3fa5:: with SMTP id a34-v6mr27841673pld.244.1539073902985; Tue, 09 Oct 2018 01:31:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539073902; cv=none; d=google.com; s=arc-20160816; b=XlF+gI0X+wqtOWQzSmuwNHeTBcUM3uxXIum8YZsqulS2nVIDpxCBZw7PpWYF5LNgJi Q6q0t+02hAvxa2NZKlwY2zCKQ5WqBj/4ASLXW/Vqs8DQ2SE26u0xmQ28XPR7XwbvTucA rPRCTZlNb8a6kU0Gl05Qq2mg7OatF8S0GuXQN8BwtLMjDsfcv2iSLHaKWulQo4KiStGQ GKAVM0h6VszzM1zflC6Du3or/bEIJZLWdz9n6PHVBldDm3ZbvjswQLiNZG0eZ5X3Tfny FZc6Q2AsKpGu/76jRdxa5PDC8yMExYhzMQ03Lbk62+0k0Fl/GycVxqHp1cNvuj/fr2Yh ufOA== 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; bh=Uyx02mSjj8ec+QDn9CZyays7JK2u6Ycaq6kNABUTWWY=; b=w/sBgvqYRoA3mJeCSjFZ4CkgFX4WY66ZHHLCGDDZZAcjYofzUVzNPciTF8io/McNc7 xOgiq1aJSb4PELoGYeBdxLR5CbgzGGJybdRrokqC+1iWQektMrQhBeyuRDaI1V77bwic STpmAlD9uNC6EBQxtXxsbLQd8Tza36sEviEVw0Zez7CEY/QNHILKqk8r3VEaAeby7emI xY0ryHPRBNMZ5E9tZHKu77pfbihiumpx1GdOtqXkLUw9lKptETCvUok7Lc8ElELBlHyR e9r8yUsFQLAvMdGAQfeFarKat0CIzKp9RMiUaQu8MHu88w8P21BvRh8Oy+iOsl/L5GDg wYeQ== 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 n135-v6si23216049pfd.38.2018.10.09.01.31.27; Tue, 09 Oct 2018 01:31:42 -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 S1726670AbeJIPqO (ORCPT + 99 others); Tue, 9 Oct 2018 11:46:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:42906 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725892AbeJIPqO (ORCPT ); Tue, 9 Oct 2018 11:46:14 -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 7A3D3B03E; Tue, 9 Oct 2018 08:30:26 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 73A4F1E3615; Tue, 9 Oct 2018 10:30:25 +0200 (CEST) Date: Tue, 9 Oct 2018 10:30:25 +0200 From: Jan Kara To: Andrew Morton Cc: john.hubbard@gmail.com, Matthew Wilcox , Michal Hocko , Christopher Lameter , Jason Gunthorpe , Dan Williams , Jan Kara , linux-mm@kvack.org, LKML , linux-rdma , linux-fsdevel@vger.kernel.org, John Hubbard , Al Viro , Jerome Glisse , Christoph Hellwig , Ralph Campbell Subject: Re: [PATCH v4 2/3] mm: introduce put_user_page*(), placeholder versions Message-ID: <20181009083025.GE11150@quack2.suse.cz> References: <20181008211623.30796-1-jhubbard@nvidia.com> <20181008211623.30796-3-jhubbard@nvidia.com> <20181008171442.d3b3a1ea07d56c26d813a11e@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181008171442.d3b3a1ea07d56c26d813a11e@linux-foundation.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 08-10-18 17:14:42, Andrew Morton wrote: > On Mon, 8 Oct 2018 14:16:22 -0700 john.hubbard@gmail.com wrote: > > + put_user_page(pages[index]); > > + } > > +} > > + > > +static inline void put_user_pages(struct page **pages, > > + unsigned long npages) > > +{ > > + unsigned long index; > > + > > + for (index = 0; index < npages; index++) > > + put_user_page(pages[index]); > > +} > > + > > Otherwise looks OK. Ish. But it would be nice if that comment were to > explain *why* get_user_pages() pages must be released with > put_user_page(). The reason is that eventually we want to track reference from GUP separately but you're right that it would be good to have a comment about that somewhere. > Also, maintainability. What happens if someone now uses put_page() by > mistake? Kernel fails in some mysterious fashion? How can we prevent > this from occurring as code evolves? Is there a cheap way of detecting > this bug at runtime? The same will happen as with any other reference counting bug - the special user reference will leak. It will be pretty hard to debug I agree. I was thinking about whether we could provide some type safety against such bugs such as get_user_pages() not returning struct page pointers but rather some other special type but it would result in a big amount of additional churn as we'd have to propagate this different type e.g. through the IO path so that IO completion routines could properly call put_user_pages(). So I'm not sure it's really worth it. Honza -- Jan Kara SUSE Labs, CR