From patchwork Thu Jul 5 17:00:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 10510043 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 680B96024A for ; Thu, 5 Jul 2018 16:57:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56ED02927A for ; Thu, 5 Jul 2018 16:57:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B0FF29282; Thu, 5 Jul 2018 16:57:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D78602927C for ; Thu, 5 Jul 2018 16:57:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B46EC6B0007; Thu, 5 Jul 2018 12:57:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AD0876B0008; Thu, 5 Jul 2018 12:57:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C0246B000A; Thu, 5 Jul 2018 12:57:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 3AA656B0007 for ; Thu, 5 Jul 2018 12:57:51 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id n2-v6so3568522edr.5 for ; Thu, 05 Jul 2018 09:57:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:references:mime-version:content-disposition:in-reply-to :user-agent; bh=b22B1J/5IusjwIjUjK7UKDVORdGVUCKrPPmI5J85+uo=; b=saCucY/03BaT7yYGaq++KklHpnZ5ytGhqMMrqXtgOm3hmVCpnkJv0T/kevLMF3B6wR PrI0ZxX9HwX0MRkF/yri+JfCRv+foluvGM8Dnl790trCQrmjJod7+fP1zyZtAK8+LiPu 10DnFvdkw0el78ix/rd/thwvuzn4Fc1XusdXQxQxSsiRD88Q1GSGa1cByZbYCRUFUCSl An1KkAWFkYAR21BEJggLzSeoPTgi7Tq8w2e0u1mmsevzh+tlthJtJhFEFoBb4WrwBCUe aNxaq/ZkXXhMzbKUd8sqkOAbwlfI3TUlu3G8Pw9kmK+84Hz1OVEpQZV8zfduEIjtBemp k1jw== X-Gm-Message-State: APt69E2OOnKpfWvv79DI/+9OhbpTbxkioqKYB7ddUozxQPSyqobDBXeo AIaVUQWUclQa9Gk7mcLOeBE5KrgE8PPvt3bAWychE0JUjXx1jiAfu/dYYl+d7QqwsggbA2rKpLF Aeec+iOmez3nMcrlsbH3cneoOPxjvPANN94hvZppGGA0NF7UI6FOS58ebHl4m3H2F+Q== X-Received: by 2002:a50:b4db:: with SMTP id x27-v6mr7574670edd.155.1530809870788; Thu, 05 Jul 2018 09:57:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeFwoO+iOCE4I2d+JSO3BU6nq1gr0+I8YFR/K0Ztg/NXrsL+aVw1LB2WYWrp8lDY8OFnlhG X-Received: by 2002:a50:b4db:: with SMTP id x27-v6mr7574615edd.155.1530809869652; Thu, 05 Jul 2018 09:57:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530809869; cv=none; d=google.com; s=arc-20160816; b=lqulDUnyd9fed3Mbj5OqT1fDJSgO15kXNku5h9cWA8xKYPiGgf3fjJ/i7LJbxRtkl2 R5kAEU70jlm78urhxm7hQ5FW/t1nN1guMWowJNtK9G/4ikS7sSYVXLcQXTmDE9RWnXpS 5JOLUI6IFA1d9GX0JB1l5fOBINpiz4ZzQM+iBHr55/Ung0/dii2a/oP8ZHNwj1BvyQRz +fzfH95P5Y5/4DUxeTy82g/om5b6HgdQXAVyo7Z13r6u5d2A8axICyUon0kz2+Sk+inj 12AuO+wEggCslpqRPNhkuHIMzHwQHnJ7V/ZV3+ABlUdON6cP8qa7IWyhSPsTP3pYa4MJ T7jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=b22B1J/5IusjwIjUjK7UKDVORdGVUCKrPPmI5J85+uo=; b=D7XeiyLBrEcOUS+ZY4bVYfL2FtL/1h/3nMqih/IkNRAtPRj0AAWvXXw9/c1jgSpVgO jfoAnk5MKw/kyJ5P4bKcVFFdylZWZ9AVJqernciCOvXkHnEfdeAg87u5Db0mSFTHFIt7 Zzo6HepviVPXUL4/hmsGmiugsWsZwvyUa6V3z6ughXfhRLGXBj2mT/VMwFg7o2G8qmJP koQfvKpe8gP+o5oA6Di2Bao1P9ukmQBKyHN+6FCXChOU3JDm6tmCIS8bs/glHiXiQAQA COc/TqFytGQHALJPM6b0EeP7/OxvLgoPS3w4JIZJs96s7RKsMPYogg3nW9VHM+tCmFj0 FGPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg.org header.s=x header.b=WNaRKbYB; spf=pass (google.com: domain of hannes@cmpxchg.org designates 85.214.110.215 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: from gum.cmpxchg.org (gum.cmpxchg.org. [85.214.110.215]) by mx.google.com with ESMTPS id 64-v6si5433799eda.432.2018.07.05.09.57.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jul 2018 09:57:49 -0700 (PDT) Received-SPF: pass (google.com: domain of hannes@cmpxchg.org designates 85.214.110.215 as permitted sender) client-ip=85.214.110.215; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg.org header.s=x header.b=WNaRKbYB; spf=pass (google.com: domain of hannes@cmpxchg.org designates 85.214.110.215 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cmpxchg.org ; s=x; 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=b22B1J/5IusjwIjUjK7UKDVORdGVUCKrPPmI5J85+uo=; b=WNaRKbYBi+yd4swivDDV8H4YDU ZVXTaIkO3e7mXuRPhMNHFP5mUQmyHtTV10RG/C+3CnGv/APOifsRHyQkhNnMf++ma+EnfnpzWX6hM JgIFmrDs5KqUoXarGXJgtnpci33yq8s35qz/wyV4Xs20+AtqrD5tCxeOuf2VPWItdLB8=; Date: Thu, 5 Jul 2018 13:00:19 -0400 From: Johannes Weiner To: Matthew Wilcox Cc: Peter Geis , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [BUG] Swap xarray workingset eviction warning. Message-ID: <20180705170019.GA14929@cmpxchg.org> References: <2920a634-0646-1500-7c4d-62c56932fe49@gmail.com> <20180702025059.GA9865@bombadil.infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180702025059.GA9865@bombadil.infradead.org> User-Agent: Mutt/1.10.0 (2018-05-17) 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: X-Virus-Scanned: ClamAV using ClamSMTP Hello, On Sun, Jul 01, 2018 at 07:50:59PM -0700, Matthew Wilcox wrote: > On Sun, Jul 01, 2018 at 07:09:41PM -0400, Peter Geis wrote: > > The warning is as follows: > > [10409.408904] ------------[ cut here ]------------ > > [10409.408912] WARNING: CPU: 0 PID: 38 at ./include/linux/xarray.h:53 > > workingset_eviction+0x14c/0x154 > > This is interesting. Here's the code that leads to the warning: > > static void *pack_shadow(int memcgid, pg_data_t *pgdat, unsigned long eviction) > { > eviction >>= bucket_order; > eviction = (eviction << MEM_CGROUP_ID_SHIFT) | memcgid; > eviction = (eviction << NODES_SHIFT) | pgdat->node_id; > > return xa_mk_value(eviction); > } > > The warning itself comes from: > > static inline void *xa_mk_value(unsigned long v) > { > WARN_ON((long)v < 0); > return (void *)((v << 1) | 1); > } > > The fact that we haven't seen this on other architectures makes me wonder > if NODES_SHIFT or MEM_CGROUP_ID_SHIFT are messed up on Tegra? > > Johannes, I wonder if you could help out here? I'm not terribly familiar > with this part of the workingset code. This could be a matter of uptime, but the warning triggers on a thing that is supposed to happen everywhere eventually. Let's fix it. The eviction timestamp is from a monotonically increasing counter that will eventually reach values high enough that the left-shifts for memcg id and node id will truncate the upper bits. The bucketing logic isn't supposed to prevent this truncation, it's just making sure that the namespace of the truncated timestamp field is big enough to cover the full range of actionable refault pages. xa_mk_value() doesn't understand that we're okay with it chopping off our upper-most bit. We shouldn't make this an API behavior, either, so let's fix the workingset code to always clear those bits before hand. Signed-off-by: Johannes Weiner diff --git a/mm/workingset.c b/mm/workingset.c index a466e731231d..1da19c04b6f7 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -173,6 +173,7 @@ static unsigned int bucket_order __read_mostly; static void *pack_shadow(int memcgid, pg_data_t *pgdat, unsigned long eviction) { eviction >>= bucket_order; + eviction &= EVICTION_MASK; eviction = (eviction << MEM_CGROUP_ID_SHIFT) | memcgid; eviction = (eviction << NODES_SHIFT) | pgdat->node_id;