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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 408A4E7D0AA for ; Thu, 21 Sep 2023 21:01:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3C7E6B0259; Thu, 21 Sep 2023 17:01:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC6516B025A; Thu, 21 Sep 2023 17:01:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 940526B025B; Thu, 21 Sep 2023 17:01:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7D2956B0259 for ; Thu, 21 Sep 2023 17:01:41 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 44D44A0E38 for ; Thu, 21 Sep 2023 21:01:41 +0000 (UTC) X-FDA: 81261826002.23.2CE8F70 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by imf21.hostedemail.com (Postfix) with ESMTP id ED9851C002A for ; Thu, 21 Sep 2023 21:01:38 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=azSp0msc; spf=pass (imf21.hostedemail.com: domain of yosryahmed@google.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695330099; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0rUsUqKbiTN+5AJFY5VneI8NJRSroN3WWkp9ziiQqp0=; b=dILMxvECWePpwKm7QtaFwSiOzm9N69BR4cwsZzfIkj8gS7cgI46pMEDyuaVPyfAOjXJwIK 5cZsb+smJUShrZEMYIv4Q6C8dT6UQCgf8qNi8BFkk09d+af+EkSL/lBZT1xQzn3WjI2VP8 QcAvkLmwIbUYiA58lBfDysGneoqRdT8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695330099; a=rsa-sha256; cv=none; b=yM3Ua9FgkE3a0F2Qid4xKadFsCPYWEAKXX1ZdXm9NK5aN7TXoslOev1AXXpQOjLKlJS4iT U8dXUBebA2OO00EzpYLhnUXlNg6EaJN9B+CJFoRKux6NJRLAUQU2XRzaKgjQg6BZzvwLGZ nKnc6isVDE5vMjWMh1hgeu0bYgQosi8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=azSp0msc; spf=pass (imf21.hostedemail.com: domain of yosryahmed@google.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-32164a6af64so1242697f8f.2 for ; Thu, 21 Sep 2023 14:01:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695330097; x=1695934897; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0rUsUqKbiTN+5AJFY5VneI8NJRSroN3WWkp9ziiQqp0=; b=azSp0msc+WY7y3a31SXeCyVp0NZEupaeSGQ13nwlX9cPFReij3ANyNYw5wOLiXXD/h 7tdX0Z4mx0fzFUr/xlvqfcy0rkeKLHDYXmKHjQYc7lI5aBw7XdFUogKRVcT4v2ofCFuD w8RNs2ab1wNTQpxxSG0LNNz5a6XHwCFZRP8A49cPouIEis6BY5bKEtOo9wB9WdFFtdpS 8GPVoMOAdbZvhzpOitfi5HPeuinL0/elwCRxdDMnSrt24Eia4h2BjvH7vT+FJCuqEWkf UmEkSyFcYLpDuOG5eE9uOwyKqWkEhKIgzc9URrsyOjp56bFG0au5HsUvUTvwKHr4mpHK 8YpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695330097; x=1695934897; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0rUsUqKbiTN+5AJFY5VneI8NJRSroN3WWkp9ziiQqp0=; b=LjbxLU7B/5ENg8/jeDfWc1Cs91EVmzBhLTk+Tzd4sTS0hkDlMs0tmPYG3azm6jMchz tsfycKRi+e6JCUrS04YP5KPKz4LcwbHF1nWvYg+Gx8WoZaJV56AYUmGQ3a+RXmfZNz/E BA/Rfn76cH4YF4GMlh9N4Ygp/y1cPxnNvBo4AFAIE5J1GT3aw7L0fKTHcuLi+iYU72x4 qN5am2CqhAInJ0PwQftmm42U+nywZSZsAW7nvbhjOJ1rGYT4WRDqaaNuVqhnUeDUz/nf hy4/p0hL2B8SfM7TYYUdVun5ram4TFSpuWi3ZW6u3tzV2TfogJ7I0fvhQAuvFsrRq+0O kXbA== X-Gm-Message-State: AOJu0YzD7op2anqnBNvmo2+8th9HXlRWxLA6A50wiYrcN+RHmIYmTkUY 2+l9tBaDqS9QKCCCSwFNXwsVWOEwSlgBfD4ts8Ez2A== X-Google-Smtp-Source: AGHT+IG+lgB6b0FlP6FTLmxGTFwXXXbuDjRWJ1vjsbR9lCrf7xYl/EarkvsXMyrafWLuLdoGAIYtDTgDuHS2NedZsQM= X-Received: by 2002:a5d:638a:0:b0:321:6fe4:d4eb with SMTP id p10-20020a5d638a000000b003216fe4d4ebmr4827582wru.2.1695330097084; Thu, 21 Sep 2023 14:01:37 -0700 (PDT) MIME-Version: 1.0 References: <20230921081057.3440885-5-yosryahmed@google.com> <202309211829.Efuqg8NE-lkp@intel.com> In-Reply-To: <202309211829.Efuqg8NE-lkp@intel.com> From: Yosry Ahmed Date: Thu, 21 Sep 2023 14:00:57 -0700 Message-ID: Subject: Re: [PATCH 4/5] mm: workingset: move the stats flush into workingset_test_recent() To: kernel test robot Cc: Andrew Morton , oe-kbuild-all@lists.linux.dev, Linux Memory Management List , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Ivan Babrou , Tejun Heo , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Waiman Long , kernel-team@cloudflare.com, Wei Xu , Greg Thelen , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: ydoxhz771bs5d6mpq5rnyu5jeq3qa8mu X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: ED9851C002A X-Rspam-User: X-HE-Tag: 1695330098-154410 X-HE-Meta: U2FsdGVkX180ag403vUe999qX2zW/qgxmVMWemgT9eAeZsRdujwDqgrS3L9KS6r6x1uRpO+TsWpbvW/mav9j1u+h3JclikdFCMNfTHbuJ2a83CNLhj2UbN7H1d4bQwfUWfsFvj0R+qWA6lD8ACqg56GI4Be/UpK/aW3UTcqHO3s1iRQd2ZURxYsjZrv52dA21xkSOxpfC4CMhD7vTTS0JJxS/FKnmUneuybs8l53QPOyspivM7wAAxejJ8+syjaS8FB6mREutiOK2zEm7scag9Ef9hkRqJhCHJFVAzw90qZ1AFCRqG3frhY2D2Yi6A4+eIwc34pjuYYXeApJj5vcKvOHQRdosibrQSGrwa7T8BMU5NYrE4HFyOwANOVgwipK47SKJQV2yTap2tFZwLkTVHhkN6pRxg6BO+rD7T8YHNIkA6IoUKZhRw6bca6LYd6YnMBN+HGeo8tvKTn/Rz3ClUP6FZupHVZejEL+hlX/6M7O+abszuCY7oY7ksfS6pKtuX2iMo16oMfLrFgCHMNTIfVIM0H4YmChREB3dLdNMfv7ziHwUzsBuazZmI7SURCIEx6G0fru2NI0AbAj1rgSZWl+/IKiQQaLp+1UXrxYcvJ3U/sXVgF+Z7gRy5llC9iNWc6JO83LhsdN+r+HOH8enQ85ABen/xVVfmxJXVsKy72x+A2O0KVICsekdprz0BB0hsbv4523AnlWzw36RgZrDNyFgZ8Czf7vvZglTQy+e8Ft6csFMxYNUsgGxV0C4Ras/luQs2phHBjkux95NJfqPwYyRGhijTnUBRBRJfJ807ogn7Azz+PFc3KI1QFCiTRQvbODgl8m2KXXrCQm0930hbi0CPR5tz7iWEHMp/Km3aAfz8Ke4q+xYu5g8cDzkT2YWsTTSEzAUxpidwpcY7BEFuxWtPe6uRUC7Hv3VMDtGXt4a5wdpUvFCC+BWCGPz0g7D20HYEsn2TqlWN88Cu+ bkDkJT00 3GEb4XKmo6Lw1amKt2Su8GHqtU629YfKTZ1GtZxfZztHGQjLcAOvWg5Alxyl/s/6kIa6h9wJrA8M+vmJ1CfmxjRX23i13nt9cRKDY+alMjySqHgqAWTmfsXYZYI/HYD9KvFqVEEi2Eidb30RPHYe0qTntIF4IPE/JHNuKtdDUJ52Xm3zGfJtgMEbZXAEhHpQ1yEUUniKOg3opHPCaCCXEd0aRIeav4kSvNJt/9CSZuS1A8SiprcJd4//kss0sv95yzqh3yVU9yviH8Fr6623UIA0v6YyVwLhA9RMxlqPMWsgRun1rAbH4o1LcFMntTsKF601jl2imtJX3u2BkXeVenFpQVacRRGaQOKISMh7r9hRVUXBOtJgHrZ0qV5H+e3+tmkdiNTyQw6hVsflbQiQn79NLA6OPY3RQ1wZ5B+yjHKCDB1kTS6HwB5EqDEw8itZ2Q5i/rpW9O5lJr9KYytrXrYvVVg== 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 Thu, Sep 21, 2023 at 4:06=E2=80=AFAM kernel test robot w= rote: > > Hi Yosry, > > kernel test robot noticed the following build errors: > > [auto build test ERROR on akpm-mm/mm-everything] > > url: https://github.com/intel-lab-lkp/linux/commits/Yosry-Ahmed/mm-mem= cg-change-flush_next_time-to-flush_last_time/20230921-161246 > base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-ev= erything > patch link: https://lore.kernel.org/r/20230921081057.3440885-5-yosryah= med%40google.com > patch subject: [PATCH 4/5] mm: workingset: move the stats flush into work= ingset_test_recent() > config: powerpc-allnoconfig (https://download.01.org/0day-ci/archive/2023= 0921/202309211829.Efuqg8NE-lkp@intel.com/config) > compiler: powerpc-linux-gcc (GCC) 13.2.0 > reproduce (this is a W=3D1 build): (https://download.01.org/0day-ci/archi= ve/20230921/202309211829.Efuqg8NE-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new vers= ion of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot > | Closes: https://lore.kernel.org/oe-kbuild-all/202309211829.Efuqg8NE-lkp= @intel.com/ > > All errors (new ones prefixed by >>): > > mm/workingset.c: In function 'workingset_test_recent': > >> mm/workingset.c:461:32: error: invalid use of undefined type 'struct m= em_cgroup' > 461 | css_get(&eviction_memcg->css); > | ^~ > Ah yes, I cannot dereference the memcg pointer here. I think we want mem_cgroup_get_from_id (a getter version of mem_cgroup_from_id) or mem_cgroup_get (similar to mem_cgroup_put) to have stubs when !CONFIG_MEMCG. I will do this change in the next version, but I'll wait for feedback on this version first. > > vim +461 mm/workingset.c > > 405 > 406 /** > 407 * workingset_test_recent - tests if the shadow entry is for a fo= lio that was > 408 * recently evicted. Also fills in @workingset with the value unp= acked from > 409 * shadow. > 410 * @shadow: the shadow entry to be tested. > 411 * @file: whether the corresponding folio is from the file lru. > 412 * @workingset: where the workingset value unpacked from shadow s= hould > 413 * be stored. > 414 * > 415 * Return: true if the shadow is for a recently evicted folio; fa= lse otherwise. > 416 */ > 417 bool workingset_test_recent(void *shadow, bool file, bool *workin= gset) > 418 { > 419 struct mem_cgroup *eviction_memcg; > 420 struct lruvec *eviction_lruvec; > 421 unsigned long refault_distance; > 422 unsigned long workingset_size; > 423 unsigned long refault; > 424 int memcgid; > 425 struct pglist_data *pgdat; > 426 unsigned long eviction; > 427 > 428 rcu_read_lock(); > 429 > 430 if (lru_gen_enabled()) { > 431 bool recent =3D lru_gen_test_recent(shadow, file, > 432 &eviction_lruve= c, &eviction, > 433 workingset); > 434 rcu_read_unlock(); > 435 return recent; > 436 } > 437 > 438 unpack_shadow(shadow, &memcgid, &pgdat, &eviction, workin= gset); > 439 eviction <<=3D bucket_order; > 440 > 441 /* > 442 * Look up the memcg associated with the stored ID. It mi= ght > 443 * have been deleted since the folio's eviction. > 444 * > 445 * Note that in rare events the ID could have been recycl= ed > 446 * for a new cgroup that refaults a shared folio. This is > 447 * impossible to tell from the available data. However, t= his > 448 * should be a rare and limited disturbance, and activati= ons > 449 * are always speculative anyway. Ultimately, it's the ag= ing > 450 * algorithm's job to shake out the minimum access freque= ncy > 451 * for the active cache. > 452 * > 453 * XXX: On !CONFIG_MEMCG, this will always return NULL; i= t > 454 * would be better if the root_mem_cgroup existed in all > 455 * configurations instead. > 456 */ > 457 eviction_memcg =3D mem_cgroup_from_id(memcgid); > 458 if (!mem_cgroup_disabled() && !eviction_memcg) > 459 return false; > 460 > > 461 css_get(&eviction_memcg->css); > 462 rcu_read_unlock(); > 463 > 464 /* Flush stats (and potentially sleep) outside the RCU re= ad section */ > 465 mem_cgroup_flush_stats_ratelimited(); > 466 > 467 eviction_lruvec =3D mem_cgroup_lruvec(eviction_memcg, pgd= at); > 468 refault =3D atomic_long_read(&eviction_lruvec->nonresiden= t_age); > 469 > 470 /* > 471 * Calculate the refault distance > 472 * > 473 * The unsigned subtraction here gives an accurate distan= ce > 474 * across nonresident_age overflows in most cases. There = is a > 475 * special case: usually, shadow entries have a short lif= etime > 476 * and are either refaulted or reclaimed along with the i= node > 477 * before they get too old. But it is not impossible for= the > 478 * nonresident_age to lap a shadow entry in the field, wh= ich > 479 * can then result in a false small refault distance, lea= ding > 480 * to a false activation should this old entry actually > 481 * refault again. However, earlier kernels used to deact= ivate > 482 * unconditionally with *every* reclaim invocation for th= e > 483 * longest time, so the occasional inappropriate activati= on > 484 * leading to pressure on the active list is not a proble= m. > 485 */ > 486 refault_distance =3D (refault - eviction) & EVICTION_MASK= ; > 487 > 488 /* > 489 * Compare the distance to the existing workingset size. = We > 490 * don't activate pages that couldn't stay resident even = if > 491 * all the memory was available to the workingset. Whethe= r > 492 * workingset competition needs to consider anon or not d= epends > 493 * on having free swap space. > 494 */ > 495 workingset_size =3D lruvec_page_state(eviction_lruvec, NR= _ACTIVE_FILE); > 496 if (!file) { > 497 workingset_size +=3D lruvec_page_state(eviction_l= ruvec, > 498 NR_INACTIVE_= FILE); > 499 } > 500 if (mem_cgroup_get_nr_swap_pages(eviction_memcg) > 0) { > 501 workingset_size +=3D lruvec_page_state(eviction_l= ruvec, > 502 NR_ACTIVE_AN= ON); > 503 if (file) { > 504 workingset_size +=3D lruvec_page_state(ev= iction_lruvec, > 505 NR_INACTIVE_= ANON); > 506 } > 507 } > 508 > 509 mem_cgroup_put(eviction_memcg); > 510 return refault_distance <=3D workingset_size; > 511 } > 512 > > -- > 0-DAY CI Kernel Test Service > https://github.com/intel/lkp-tests/wiki