Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1494315imd; Thu, 1 Nov 2018 17:03:50 -0700 (PDT) X-Google-Smtp-Source: AJdET5ci2IRDGRqJ5Fl0CKglrpvaKXyZ1kVbzlqNGj6wunokyD1y+r6q9/n61nxWLtPMDMc/S1rq X-Received: by 2002:a63:c24c:: with SMTP id l12mr9013220pgg.146.1541117030046; Thu, 01 Nov 2018 17:03:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541117030; cv=none; d=google.com; s=arc-20160816; b=IMty9Q5QZTV3Ng18U26gNhVuuk9+8MJsJxvmNVyC0wTD2UclqoTPXAucRstTMUoO/4 OrLV/I5mpNm/UOJUCkk1MBqPNocW/HagVu+bkL8gY8IkCzZpmkV8DERadohZxHk8Q+vD Oc5RsUokLvq/xmlj4Y3LeKN2cOscFSSmKMAPkG90lHGQdwxLjKoszRW9VOQdFqxKJgWZ liXjhdB1Zhs0oPfd+L4r1feoo1khP71Bm634hO2Go7Q89MrEdb/f1Z9x7C31+0QoNrl1 zGsUne45O+HLE6PHmV0dJBud8chWNxyM1VBdZNnGCJoDqIb0MQDFy2YPZ1exNW7FEKV3 k7jw== 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; bh=VUoxclPY/cYAQeJKl3xtp7ETpqx0IXVnEk7Sf+Q/k3E=; b=SGgXQEhkWby9Q4Y4W+B872ooykF8nb3v3RGyTW5q+uTtdGff/uuWpraglMpWrALIGM i9CDgjBn0mjTKo9x3Sh2go/h0D6hXWXzEPQFl69NTO6kPHg946fIXApdMSpUMePJjSiv uhs21t+ordSfYVEoNxJwws71ghVNEsk+BG03Nn6+EsXSHyX2X0mRJL5RuJCRG+DZWUma PZgY76xoxMCyQyt+4YBNFyWgAoYGW/tOkbNEgX6j3TMq6rPY/a5iFQADXQt6+qUaCmIy lk61tGK09xe7SyY6ODmxZy7IEvAjsacqbVKf1WMirzVxum5hSCVMEO6OnZw7q4tdAxEd c7gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FvtLBmv2; 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 a34si1235985pgb.458.2018.11.01.17.03.33; Thu, 01 Nov 2018 17:03:50 -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=FvtLBmv2; 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 S1728296AbeKBJIU (ORCPT + 99 others); Fri, 2 Nov 2018 05:08:20 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38096 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728169AbeKBJIT (ORCPT ); Fri, 2 Nov 2018 05:08:19 -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=VUoxclPY/cYAQeJKl3xtp7ETpqx0IXVnEk7Sf+Q/k3E=; b=FvtLBmv2WknZ11L5+CZMemsQD Yv/7S+IomXVTWSIgvW+2jadmvDDFZNhWpw+iFd/B4mxBb3S8HReg8hRd04xbA2/WRUcvBIoaVeSpb kQVi1ULXc2ts1lq99tmblCuT9yNVKjFuH0mYkGkKW/++Th0fqaNU4OZMV8WqymBMz4yO+2uW085wM QviBD17kf/dyDBw4n2eIhRIPzz+bW8ti/VuXYsMTO/AuEWugx4oUZqnzaRty1JrZdpVm9IDpILuCz ox/OPyt3dOEhsSqH8xjeozCHy60mBdRZcw2KKf/9lK1Ar3CAMJHnepGuaAhWeGOYfY4JDRcXm3cwB aXZg4Ca2w==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gIMvc-0004z4-7T; Fri, 02 Nov 2018 00:03:08 +0000 Date: Thu, 1 Nov 2018 17:03:08 -0700 From: Matthew Wilcox To: Joe Perches Cc: Andrew Morton , miles.chen@mediatek.com, Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com, Michal Hocko Subject: Re: [PATCH v4] mm/page_owner: clamp read count to PAGE_SIZE Message-ID: <20181102000307.GO10491@bombadil.infradead.org> References: <1541091607-27402-1-git-send-email-miles.chen@mediatek.com> <20181101144723.3ddc1fa1ab7f81184bc2fdb8@linux-foundation.org> <3c81f60ac1ff270df972ded4128a7dbf41a91113.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3c81f60ac1ff270df972ded4128a7dbf41a91113.camel@perches.com> 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, Nov 01, 2018 at 04:30:12PM -0700, Joe Perches wrote: > On Thu, 2018-11-01 at 14:47 -0700, Andrew Morton wrote: > > +++ a/mm/page_owner.c > > @@ -351,7 +351,7 @@ print_page_owner(char __user *buf, size_ > > .skip = 0 > > }; > > > > - count = count > PAGE_SIZE ? PAGE_SIZE : count; > > + count = min_t(size_t, count, PAGE_SIZE); > > kbuf = kmalloc(count, GFP_KERNEL); > > if (!kbuf) > > return -ENOMEM; > > A bit tidier still might be > > if (count > PAGE_SIZE) > count = PAGE_SIZE; > > as that would not always cause a write back to count. 90% chance 'count' is already in a register and will stay there. 99.9% chance that if it's not in a register, it's on the top of the stack, which is by definition a hot, local, dirty cacheline. What you're saying makes sense for a struct which might well be in a shared cacheline state. But for a function-local variable? No.