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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 42708C433DB for ; Tue, 19 Jan 2021 20:48:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BB58922CE3 for ; Tue, 19 Jan 2021 20:48:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB58922CE3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 12AE86B0005; Tue, 19 Jan 2021 15:48:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DC426B0006; Tue, 19 Jan 2021 15:48:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBEF26B0007; Tue, 19 Jan 2021 15:48:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0131.hostedemail.com [216.40.44.131]) by kanga.kvack.org (Postfix) with ESMTP id D4B266B0005 for ; Tue, 19 Jan 2021 15:48:49 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 91A4D181AF5C6 for ; Tue, 19 Jan 2021 20:48:49 +0000 (UTC) X-FDA: 77723713578.22.books41_2a11f3f27554 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 5040B18038E60 for ; Tue, 19 Jan 2021 20:48:49 +0000 (UTC) X-HE-Tag: books41_2a11f3f27554 X-Filterd-Recvd-Size: 5106 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Tue, 19 Jan 2021 20:48:48 +0000 (UTC) Received: by mail-ed1-f41.google.com with SMTP id c6so16064448ede.0 for ; Tue, 19 Jan 2021 12:48:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pkvwNS+El3HA8WD1wRriEqmYtWWjP+w29biUdXgRxJU=; b=dSjBpa02JgglRGcx2/84mL0OXTCylHCQoDPgRwYBgrdb1HeoN9e0E5ozaqSaHQmRJQ JEDFtdNYkjnRNQeiNWezHyCjWUGH/2rg0nNXA2QnrjGwXXd025IdsoTLQdA1uxQjS26+ cPfLfAiBXrj9cUDr24KbI0YvsYJLrKTOlLQ32ydg1HKyynrHQjQKJJ0mAgh3hNwrLJOz zOStGtE9m+tRTCJAg3iZb5yyW4gCYRrXrq1RR6n6A1p7VVWXhf5XUvE71xzvcQbzG3+/ E8PEOsIclx3toavM02OCpAK44+Zx/5/MsgZKKBWQUOVOYE8kOLdYwf9kSTkRErEiWDiw FCKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pkvwNS+El3HA8WD1wRriEqmYtWWjP+w29biUdXgRxJU=; b=ZCqU5Q3BhMog5BeOTecQvx8fd/7Ivk+70CVKXPk8jAIv8N8dOgx6DpIATXIT96ji58 Ep9nnhpTuykRrsZYPVps6GgSWNZ9olzqn8Z2TukAc9MCjWtRtV/OC3v+7cS49DkxePZC cwd6+L2OzrYsnz39Kk/XzhzzSeBppdpLMeLtAmz/Y/lrxB2/9qvA9ytSftrlx5JfXaLD 8SqkrSuCij9k1ztkFsQyOHoUrJu9WklTwO0uy/DirFfu1Jdj6MtHeneyhreBDN62640m S1zRZR7rfQJhkyPnWbJj2eeRt8OWwyH38/dMDFoqr94eaHWtl64BuyCxIRhvopXgmbzc I7Wg== X-Gm-Message-State: AOAM531Ift6M4Mxv+38XgsLr2fEOr4Ky6b97bQXHIEvrGfK8Scsq2C/9 ijapv1blahDSezsGqQrMekEJJ34n8K3eX6u1DPSThg== X-Google-Smtp-Source: ABdhPJwV9Ku3qyoq2kBTxOz6KgfvN81wwX3pQbkfxuQ92kJTO4QXY1Tul7nDV11Bbxd6oY64UzZ7b7Hp4cw5mc6tznY= X-Received: by 2002:a05:6402:3508:: with SMTP id b8mr4912140edd.341.1611089327572; Tue, 19 Jan 2021 12:48:47 -0800 (PST) MIME-Version: 1.0 References: <20210119043920.155044-1-pasha.tatashin@soleen.com> <20210119043920.155044-9-pasha.tatashin@soleen.com> <20210119183013.GB4605@ziepe.ca> <20210119184751.GD4605@ziepe.ca> In-Reply-To: From: Pavel Tatashin Date: Tue, 19 Jan 2021 15:48:11 -0500 Message-ID: Subject: Re: [PATCH v5 08/14] mm/gup: do not allow zero page for pinned pages To: Jason Gunthorpe Cc: LKML , linux-mm , Andrew Morton , Vlastimil Babka , Michal Hocko , David Hildenbrand , Oscar Salvador , Dan Williams , Sasha Levin , Tyler Hicks , Joonsoo Kim , mike.kravetz@oracle.com, Steven Rostedt , Ingo Molnar , Peter Zijlstra , Mel Gorman , Matthew Wilcox , David Rientjes , John Hubbard , Linux Doc Mailing List , Ira Weiny , linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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: > I was thinking about a use case where userland would pin an address > without FOLL_WRITE, because the PTE for that address is not going to > be writable, but some device via DMA will write to it. Now, if we got > a zero page we have a problem... If this usecase is not valid then the > fix for movable zero page is make the zero page always come from a > non-movable zone so we do not need to isolate it during migration, and > so the memory can be offlined later. I looked into making zero_page non-movable, and I am confused here. huge zero page is already not movable: get_huge_zero_page() zero_page = alloc_pages((GFP_TRANSHUGE | __GFP_ZERO) & ~__GFP_MOVABLE, ... Base zero page can be in a movable zone, which is a bug: if there are references to zero page, that page cannot be migrated, and we won't be hot-remove memory area where that page is located. On x86, zero page should always come from the bottom 4G of physical memory / DMA32 ZONE. However, I see that sometimes it is not (I reproduce in QEMU emulator): QEMU instance with 16G of memory and kernelcore=5G Boot#1: zero_pfn 48a8d zero_pfn zone: ZONE_DMA32 Boot#2: zero_pfn 20168d zero_pfn zone: ZONE_MOVABLE (???) The problem is that the x86 zero page comes from the .bss segment: https://soleen.com/source/xref/linux/arch/x86/kernel/head_64.S?r=31d85460#583 Which, I thought would always be set within the first 4G of physical memory. What is going on here? Pasha