From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F406CC3F68F for ; Fri, 14 Feb 2020 13:52:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AC3C3222C4 for ; Fri, 14 Feb 2020 13:52:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="2TKMT+CY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC3C3222C4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 486FF6B0621; Fri, 14 Feb 2020 08:52:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 439BD6B0623; Fri, 14 Feb 2020 08:52:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34F036B0624; Fri, 14 Feb 2020 08:52:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0097.hostedemail.com [216.40.44.97]) by kanga.kvack.org (Postfix) with ESMTP id 1FF356B0621 for ; Fri, 14 Feb 2020 08:52:29 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D2E844DCF for ; Fri, 14 Feb 2020 13:52:28 +0000 (UTC) X-FDA: 76488872376.11.rose46_32a9fca5ead1a X-HE-Tag: rose46_32a9fca5ead1a X-Filterd-Recvd-Size: 4574 Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Fri, 14 Feb 2020 13:52:28 +0000 (UTC) Received: by mail-lf1-f66.google.com with SMTP id 203so6780347lfa.12 for ; Fri, 14 Feb 2020 05:52:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tdtqJsclM4uhuI49pOeI8DovFeuAeipuZdS8MF+ZWv4=; b=2TKMT+CYVGT6tGMCX3C6ArI+zF6FCg+KFoCVV+Dp1uBA+j0Bypp6RS3QcMMgk9JKK2 +5FkZGsWlh+c73qUM1dgCbXrCaIDpNSxv5yZ4QZGVultrVfS0230WquGpTX7bWMQZwRL Itk86oLVC12ZSIKyd+5Sx5M0SqXlOC3Y1FMECprDAznUARuH7ImGLSbmH4a9xgwU8KDC H7AaI8p81Izim+CXybf3/U1g3yEyxDRIfmr7NBAeUS+PpoX/CPSvou/vpz3us8w80e0/ CgqPwGd05MoNEx6XvJl4K5/6Pn2O/mUOFIQN+NUEkqVeV/p3NW0POTievY/0WitDLk0/ XyNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tdtqJsclM4uhuI49pOeI8DovFeuAeipuZdS8MF+ZWv4=; b=TLDspU4HFbbsLGVjWeIMA6iTGWSEATKDGFDkp0gw/ZVjiQiJfmo4UpR7U5dJnj7Tj+ N2SW39Kr3mIW6YYP/XjgwTgZEIPls9DNMyrjH7RzsNPfj0yqMNgEkhqbDhiPJy+dY6pW i33h+g9A7ZMhUH6pFZomW8hEj3Yg3I+gu51SiM/FD6roBVkthu0DNv0yt3iJXH/KsPPR 5jJqbIAxGaWuyDXRHy4AnWyCK7VXK+nU86eua0+KhEd9DyfRvzDrnWPzdkI2QQ5KhLYX 2cdjMyjLBhMzvzpmKSVz3Gq36AeU7jKREio833Y/wFgyJioU15LCLeUyiRkEWwn5lx4B LQKA== X-Gm-Message-State: APjAAAUT1vgtenqrPlT0JE0l+9htbs9kcaBFdsEfkA90bARWIVHm7vON hg3D3uBLnQtLncpuZlzO/l4ohw== X-Google-Smtp-Source: APXvYqxKZSFPG4dqXvYMd4rmSifXuXeg3DODSZO8QZQljvwGRQPXEzK9MqFBoZOwwF5DbIqRkuXUEQ== X-Received: by 2002:a05:6512:4c6:: with SMTP id w6mr1721466lfq.157.1581688346526; Fri, 14 Feb 2020 05:52:26 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id 23sm3661546ljw.31.2020.02.14.05.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2020 05:52:25 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id 3DAEF100F7E; Fri, 14 Feb 2020 16:52:48 +0300 (+03) Date: Fri, 14 Feb 2020 16:52:48 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 13/25] fs: Add zero_user_large Message-ID: <20200214135248.zqcqx3erb4pnlvmu@box> References: <20200212041845.25879-1-willy@infradead.org> <20200212041845.25879-14-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200212041845.25879-14-willy@infradead.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Feb 11, 2020 at 08:18:33PM -0800, Matthew Wilcox wrote: > From: "Matthew Wilcox (Oracle)" > > We can't kmap() a THP, so add a wrapper around zero_user() for large > pages. I would rather address it closer to the root: make zero_user_segments() handle compound pages. > > Signed-off-by: Matthew Wilcox (Oracle) > --- > include/linux/highmem.h | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/include/linux/highmem.h b/include/linux/highmem.h > index ea5cdbd8c2c3..4465b8784353 100644 > --- a/include/linux/highmem.h > +++ b/include/linux/highmem.h > @@ -245,6 +245,28 @@ static inline void zero_user(struct page *page, > zero_user_segments(page, start, start + size, 0, 0); > } > > +static inline void zero_user_large(struct page *page, > + unsigned start, unsigned size) > +{ > + unsigned int i; > + > + for (i = 0; i < thp_order(page); i++) { > + if (start > PAGE_SIZE) { Off-by-one? >= ? > + start -= PAGE_SIZE; > + } else { > + unsigned this_size = size; > + > + if (size > (PAGE_SIZE - start)) > + this_size = PAGE_SIZE - start; > + zero_user(page + i, start, this_size); > + start = 0; > + size -= this_size; > + if (!size) > + break; > + } > + } > +} > + > #ifndef __HAVE_ARCH_COPY_USER_HIGHPAGE > > static inline void copy_user_highpage(struct page *to, struct page *from, > -- > 2.25.0 > > -- Kirill A. Shutemov