Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3967447imm; Tue, 11 Sep 2018 05:04:35 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYuXP1i/5aJp7U0rBlKsjn2MhVceUST0iPNykoUzY4MUMFZt19+uLPKlSgLRX+FsgZ3WyzM X-Received: by 2002:a62:6f87:: with SMTP id k129-v6mr28908966pfc.26.1536667475012; Tue, 11 Sep 2018 05:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536667474; cv=none; d=google.com; s=arc-20160816; b=KvIezwVt3TC3xKjP+Ni+v8qYZJftodWu+KX6yV7LxuTnIUI79TntuI3GYz3zzJ3IBQ 5ooDH2NEZ6lyZSoZk8gyLm51gQu3fJlPfUkcHlw3e8jHlh8NGCEONhMwd2FT2YRaPWU0 v016jFFISu7vFu7fAhX/Xaw8zDbRYpU/3xugMWJgjL+8rq3Q2cS7Kwldli8ZKdMZJVJU dCn+V9oM7WvI/I3OWS66A7tRpAywhIoJO1/e49iGwCjO71AGlLjA3AQ6A07B7k8+H+r9 hPEoijOOetkloXuEnbrUOWIg2oC/xbY2514wt5GDG+3bSmMCINNDjQ2JgVJz3jOKO3vE qvWw== 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=xkzHUM70lzHw+Yc579EtZNj1ZXyB3jnxAS+/g+9tiAk=; b=wUAytPxAhYGGA6ey1iXuktF/QEUSqeydOP8+c/E5odUJ61WiO1sTtr0AX8wrG0SlJy oXc7lYZxxrTdfoWczt8aCDmuZYun8KF/DhUC51Op6SP6Lut6bAv1ifEoAiW83tvL/91v RWiAyH6tH0v5fmZe+iQ9GP4U0P5vWVJB0vsvrkhagawJvYjlqhYNtbLpSwmi5zNKLZPE NBmq4jPahZ1dpR7F6IceD93KgupwuGfAqcYCzxNygfq3S4EX91/O55dcE0656EdABrWz rZNX6rkBjr8Sy1uUDwmUkvKKWHCS6PrXXIFEeRIhu7JZLeR4JAb5AqqcN8lFL5oKWtcI 7rmQ== 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 d3-v6si20598108pgk.610.2018.09.11.05.04.06; Tue, 11 Sep 2018 05:04:34 -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 S1727720AbeIKRCy (ORCPT + 99 others); Tue, 11 Sep 2018 13:02:54 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59434 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726678AbeIKRCx (ORCPT ); Tue, 11 Sep 2018 13:02:53 -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 7C435400738B; Tue, 11 Sep 2018 12:03:51 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id C16D4111AF29; Tue, 11 Sep 2018 12:03:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 16EBF16E28; Tue, 11 Sep 2018 14:03:50 +0200 (CEST) Date: Tue, 11 Sep 2018 14:03:50 +0200 From: Gerd Hoffmann To: Laurent Pinchart Cc: dri-devel@lists.freedesktop.org, David Airlie , Tomeu Vizoso , Daniel Vetter , Jonathan Corbet , Sumit Semwal , Shuah Khan , "open list:DOCUMENTATION" , open list , "open list:DMA BUFFER SHARING FRAMEWORK" , "moderated list:DMA BUFFER SHARING FRAMEWORK" , "open list:KERNEL SELFTEST FRAMEWORK" , linux-api@vger.kernel.org Subject: Re: [PATCH v7] Add udmabuf misc device Message-ID: <20180911120350.qtacdf2otwzuywv2@sirius.home.kraxel.org> References: <20180827093444.23623-1-kraxel@redhat.com> <21053714.0Xa7F2u2PE@avalon> <20180911065014.vo6qp6hkb7cjftdc@sirius.home.kraxel.org> <18750721.r4B5nx0M26@avalon> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18750721.r4B5nx0M26@avalon> User-Agent: NeoMutt/20180716 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]); Tue, 11 Sep 2018 12:03:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 11 Sep 2018 12:03:51 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > >> + if (WARN_ON(vmf->pgoff >= ubuf->pagecount)) > > >> + return VM_FAULT_SIGBUS; > > > > > > Just curious, when do you expect this to happen ? > > > > It should not. If it actually happens it would be a bug somewhere, > > thats why the WARN_ON. > > But you seem to consider that this condition that should never happen still > has a high enough chance of happening that it's worth a WARN_ON(). I was > wondering why this one in particular, and not other conditions that also can't > happen and are not checked through the code. Added it while writing the code, to get any coding mistake I make flagged right away instead of things exploding later on. I can drop it. > > >> + ubuf = kzalloc(sizeof(struct udmabuf), GFP_KERNEL); > > > > > > sizeof(*ubuf) > > > > Why? Should not make a difference ... > > Because the day we replace > > struct udmabuf *ubuf; > > with > > struct udmabuf_ext *ubuf; > > and forget to change the next line, we'll introduce a bug. That's why > sizeof(variable) is preferred over sizeof(type). Another reason is that I can > easily see that > > ubuf = kzalloc(sizeof(*ubuf), GFP_KERNEL); > > is correct, while using sizeof(type) requires me to go and look up the > declaration of the variable. So it simplifies review, ok, will change it. BTW: Maybe the kernel should pick up a neat trick from glib: g_new0() is a macro which takes the type instead of the size as first argument, and it casts the return value to that type. So the compiler will throw warnings in case of a mismatch. That'll work better than depending purely on the coder being careful and review catching the remaining issues. cheers, Gerd