Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1453451ybb; Thu, 2 Apr 2020 00:44:50 -0700 (PDT) X-Google-Smtp-Source: APiQypJ+86z1nUK/2jjLaDTqsTtnTS/xwNnmWvYhY1UVnPDOv8Aso7rjtbOBrsBsl5me+GLdRkDO X-Received: by 2002:a4a:e9fc:: with SMTP id w28mr1687054ooc.98.1585813489864; Thu, 02 Apr 2020 00:44:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585813489; cv=none; d=google.com; s=arc-20160816; b=wvykqkhfNiaABwunEt+t1nzfenKEReq2U2l/+9MEV2Zpd0PUuocNshFH90bmuKCJgP bzGkqXzdXOCnFAChNtpijdyn6IVXNHcNYFZmQHOUZ+3dJgPD7Ue3hio0NAu8t77pXBai ARQNaxaCuWCgzVrHTxHZL4j4e/ELrWWX+uOWJAUtHW/E66lom7z2Ak7N6v34TvVl48gG HULdX0qm1aA91MIahqWtoZMcxhWExGzX/v63kF1uYP0Y8vWkb++y8XvitMb7EN1EXSEG k5VBkuo2HWD01iIJHpu/h9yoXxJ4zhBXZSlBMoVnDTumj0AfUvciDUmIIu2uAMRf0sJp YARw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=UBE7VI9FnbtBHIdXLo3J25c1IHbGbjYoWi7ozq8GSkw=; b=WgwkJ5FNmPOqis9MD6eGesLZ46TfJjbnBg6jpHblt76Q6KA+jigpVWG4t0xZoZ+/vz g6OnWKgcRivDO717bjziUyb2O8vwm++k7ajaEOjmKomzGx5Rd3quDFDyyPqpe75n6Qv2 eHSxp5UPKpEArujGc7olAxksTOmmHlXuCT6eSTOJm28cvyfyK0Q6A7+8/UHB29W5yB5s UBJgStZ5r4IPL+cpTo1fg9pjB3gi3b4ZvbvD4iZgRKOGxtfJytK5j8D+ZqoNprH3DMnu flHLpr1dPa1ZbV7cLurh7qAn51CObER6oeHyIjqGPZ4oIIroSY/LfMxvt+qAOmZFqw0u 221g== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u28si2250560otg.14.2020.04.02.00.44.37; Thu, 02 Apr 2020 00:44:49 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387431AbgDBHoR (ORCPT + 99 others); Thu, 2 Apr 2020 03:44:17 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33720 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725965AbgDBHoR (ORCPT ); Thu, 2 Apr 2020 03:44:17 -0400 Received: by mail-wr1-f65.google.com with SMTP id a25so2998287wrd.0 for ; Thu, 02 Apr 2020 00:44:14 -0700 (PDT) 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=UBE7VI9FnbtBHIdXLo3J25c1IHbGbjYoWi7ozq8GSkw=; b=ApGDE3OYM6E5igBx/hnbEBtdARdtNhcW/goX4e3tkKK1RsrQ9hiTXGK/6dj4/CS7dU efWrSq+htbilFm/Vwnvd0Q8rCmOMVpPEKWuma03dId7qlJb5IeDOE4wLiXjH6CEdz/4r lea15IYQJHu07LF9fcg08rSemd3CJJILhJwBMAJEGOHFwUI8IBge2+tyVlMPX6auEM2H jDB3ZZuwZj8AI7KhCCrp+m+5LowBQJBECaLP5CxGpHcMOJuMp8Xvy5hQhLuZhiR4XZa5 7/OZwwljski8IEH0z3LRDGlktwDZa/eHxPVDrTn2ffoVtdxLD9+JW1MXo+/a4Fchp7kt u6fw== X-Gm-Message-State: AGi0PuY3ItdQsDUBOmHVDr80IjKWn7BKExsNO2s7r0Rx6skHIpDFIY/O ItsZQmpKv7gMspbXQ4jOfEI= X-Received: by 2002:adf:97c8:: with SMTP id t8mr2054345wrb.319.1585813453828; Thu, 02 Apr 2020 00:44:13 -0700 (PDT) Received: from localhost (ip-37-188-180-223.eurotel.cz. [37.188.180.223]) by smtp.gmail.com with ESMTPSA id b82sm5518287wme.25.2020.04.02.00.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 00:44:12 -0700 (PDT) Date: Thu, 2 Apr 2020 09:44:11 +0200 From: Michal Hocko To: "Huang, Ying" Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zi Yan , Andrea Arcangeli , "Kirill A . Shutemov" , Vlastimil Babka , Alexey Dobriyan , Konstantin Khlebnikov , =?utf-8?B?Suly9G1l?= Glisse , Yang Shi Subject: Re: [PATCH -V2] /proc/PID/smaps: Add PMD migration entry parsing Message-ID: <20200402074411.GH22681@dhcp22.suse.cz> References: <20200402020031.1611223-1-ying.huang@intel.com> <20200402064437.GC22681@dhcp22.suse.cz> <87zhbufjyc.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87zhbufjyc.fsf@yhuang-dev.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 02-04-20 15:03:23, Huang, Ying wrote: > Michal Hocko writes: > > > On Thu 02-04-20 10:00:31, Huang, Ying wrote: > >> From: Huang Ying > >> > >> Now, when read /proc/PID/smaps, the PMD migration entry in page table is simply > >> ignored. To improve the accuracy of /proc/PID/smaps, its parsing and processing > >> is added. > >> > >> Before the patch, for a fully populated 400 MB anonymous VMA, sometimes some THP > >> pages under migration may be lost as follows. > > > > Interesting. How did you reproduce this? > > [...] > > I run the pmbench in background to eat memory, then run > `/usr/bin/migratepages` and `cat /proc/PID/smaps` every second. The > issue can be reproduced within 60 seconds. Please add that information to the changelog. I was probably too optimistic about the migration duration because I found it highly unlikely to be visible. I was clearly wrong here. > >> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c > >> index 8d382d4ec067..9c72f9ce2dd8 100644 > >> --- a/fs/proc/task_mmu.c > >> +++ b/fs/proc/task_mmu.c > >> @@ -546,10 +546,19 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, > >> struct mem_size_stats *mss = walk->private; > >> struct vm_area_struct *vma = walk->vma; > >> bool locked = !!(vma->vm_flags & VM_LOCKED); > >> - struct page *page; > >> + struct page *page = NULL; > >> > >> - /* FOLL_DUMP will return -EFAULT on huge zero page */ > >> - page = follow_trans_huge_pmd(vma, addr, pmd, FOLL_DUMP); > >> + if (pmd_present(*pmd)) { > >> + /* FOLL_DUMP will return -EFAULT on huge zero page */ > >> + page = follow_trans_huge_pmd(vma, addr, pmd, FOLL_DUMP); > >> + } else if (unlikely(thp_migration_supported() && is_swap_pmd(*pmd))) { > >> + swp_entry_t entry = pmd_to_swp_entry(*pmd); > >> + > >> + if (is_migration_entry(entry)) > >> + page = migration_entry_to_page(entry); > >> + else > >> + VM_WARN_ON_ONCE(1); > > > > Could you explain why do we need this WARN_ON? I haven't really checked > > the swap support for THP but cannot we have normal swap pmd entries? > > I have some patches to add the swap pmd entry support, but they haven't > been merged yet. > > Similar checks are for all THP migration code paths, so I follow the > same style. I haven't checked other migration code paths but what is the reason to add the warning here? Even if this shouldn't happen, smaps is perfectly fine to ignore that situation, no? -- Michal Hocko SUSE Labs