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=-2.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 D4E3CC43603 for ; Tue, 10 Dec 2019 17:04:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8AB662073D for ; Tue, 10 Dec 2019 17:04:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="zphgx8SE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8AB662073D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 241946B2D67; Tue, 10 Dec 2019 12:04:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 218646B2D68; Tue, 10 Dec 2019 12:04:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 107F66B2D69; Tue, 10 Dec 2019 12:04:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0185.hostedemail.com [216.40.44.185]) by kanga.kvack.org (Postfix) with ESMTP id EAA0C6B2D67 for ; Tue, 10 Dec 2019 12:04:24 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id A3C9CBBFC for ; Tue, 10 Dec 2019 17:04:24 +0000 (UTC) X-FDA: 76249855248.04.EFE239B Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 5079E801D23E for ; Tue, 10 Dec 2019 17:02:24 +0000 (UTC) X-HE-Tag: dolls71_31dff2faff136 X-Filterd-Recvd-Size: 4801 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Dec 2019 17:02:22 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id g6so110749plp.7 for ; Tue, 10 Dec 2019 09:02:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=rRqPLE4dXnF4n2+9+iyu9OEiIv3PDL4Q8KoD2x2W6Gk=; b=zphgx8SE0ecZBftbR1vGSNvgVTJ+UjBN6JyiXOeU4wVBNAWrP0m3GLK2dU0i2R7uOv Pj0Oki2wCvjCoA/DFnJKkERIZqI4Z4mmudNnH6LdOZZqSblGL9eBdTRSXxpAnmnFjnjW r0O4e5y1OnxroqqTs2NAwnObYlrAlCINpmBb4DcCY1hQyvd6Ldz6PxFAOfkFktW86DDf TtohfMDX7XOtvt8Q8f4yXJUGDT8EPbRtAEDtCoAt/LkftPIQ7RyE9zTPuB7OwVqWt2KE CrfpZ/jPduPdklP9julfsqkFbMq5c+47BIo3FDCXFWaAc0vY6AlBj21swzrhnepuYjDN Ydgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=rRqPLE4dXnF4n2+9+iyu9OEiIv3PDL4Q8KoD2x2W6Gk=; b=YPblJWHprR/lbeBgL71I5l66R0kmxDE4h7gTHROP4ZynvwgJ9FN1DqChVgPng27zNb 6oYnCC+wPnDxZQZFAbCok7dGBnEP50X+Q2kPO7iJpg6zOEXAF6xlKqVun0asKFGMvYGX Kg14mEhUyYLPUBRUUMv/GnNg1mMufAwoTqlOc6zIAcWY5L9BfMpCXfGlB9GEHjXn3nUB qZVV8AQqk8sn8oqNaeKYuDQVO0E+qbIjvjjCUgtRyzZhSSFR23J2gWeMSQOa2t0Hsmdd fOpc4tdzypPKvCFZtgMdPVq29x+CKJI00uo/hdROjLWcGBMidkZrWpDXKHWF8CkqSILh KGww== X-Gm-Message-State: APjAAAXR3jWEkteI2KSqmngfTzS+inrgNAvM3FmX6gA9TFZDTi8YHPef uq0p5fC6fCFXFw2GymTobg2bzg== X-Google-Smtp-Source: APXvYqyd0yR6JXRmVjr21noLl8IiI3HSB25yPpBjQvYCieXOg4m2hODG+fIOIbjIJGZGkXWU0Riafw== X-Received: by 2002:a17:902:bc8b:: with SMTP id bb11mr24150424plb.52.1575997341297; Tue, 10 Dec 2019 09:02:21 -0800 (PST) Received: from ?IPv6:2620:10d:c081:1131::1365? ([2620:10d:c090:180::b7af]) by smtp.gmail.com with ESMTPSA id c19sm4487904pfc.144.2019.12.10.09.02.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Dec 2019 09:02:20 -0800 (PST) Subject: Re: [PATCH 3/5] mm: make buffered writes work with RWF_UNCACHED To: Matthew Wilcox Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org References: <20191210162454.8608-1-axboe@kernel.dk> <20191210162454.8608-4-axboe@kernel.dk> <20191210165532.GJ32169@bombadil.infradead.org> From: Jens Axboe Message-ID: <721d8d7e-9e24-bded-a3c0-fa5bf433e129@kernel.dk> Date: Tue, 10 Dec 2019 10:02:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: <20191210165532.GJ32169@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 12/10/19 9:55 AM, Matthew Wilcox wrote: > On Tue, Dec 10, 2019 at 09:24:52AM -0700, Jens Axboe wrote: >> +/* >> + * Start writeback on the pages in pgs[], and then try and remove those pages >> + * from the page cached. Used with RWF_UNCACHED. >> + */ >> +void write_drop_cached_pages(struct page **pgs, struct address_space *mapping, >> + unsigned *nr) > > It would seem more natural to use a pagevec instead of pgs/nr. I did look into that, but they are intertwined with LRU etc. I deliberately avoided the LRU on the read side, as it adds noticeable overhead and gains us nothing since the pages will be dropped agian. >> +{ >> + loff_t start, end; >> + int i; >> + >> + end = 0; >> + start = LLONG_MAX; >> + for (i = 0; i < *nr; i++) { >> + struct page *page = pgs[i]; >> + loff_t off; >> + >> + off = (loff_t) page_to_index(page) << PAGE_SHIFT; > > Isn't that page_offset()? I guess it is! I'll make that change. >> + __filemap_fdatawrite_range(mapping, start, end, WB_SYNC_NONE); >> + >> + for (i = 0; i < *nr; i++) { >> + struct page *page = pgs[i]; >> + >> + lock_page(page); >> + if (page->mapping == mapping) { > > So you're protecting against the page being freed and reallocated to a > different file, but not against the page being freed and reallocated > to a location in the same file which is outside (start, end)? I guess so, we can add that too, probably just check if the index is still the same. More of a behavioral thing, shouldn't be any correctness issues there. -- Jens Axboe