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 8C99DECAAD8 for ; Wed, 14 Sep 2022 06:33:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 03D888D0002; Wed, 14 Sep 2022 02:33:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F2F148D0001; Wed, 14 Sep 2022 02:33:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF7CD8D0002; Wed, 14 Sep 2022 02:33:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CC9BD8D0001 for ; Wed, 14 Sep 2022 02:33:58 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A232A1C6870 for ; Wed, 14 Sep 2022 06:33:58 +0000 (UTC) X-FDA: 79909725756.10.A734F74 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf02.hostedemail.com (Postfix) with ESMTP id 5653E800AD for ; Wed, 14 Sep 2022 06:33:58 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id q3so13552776pjg.3 for ; Tue, 13 Sep 2022 23:33:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=Snq77pgWGuBdhSsfi8MS1XPk8bTI55UIIEAHYPZaB1Y=; b=aHOWylDRjar56CZgOKRun2pNmDxLm7upcYLBzSAj46O4d+0lTwTQsK41EDexvCujaB dultCKuPSlmmGBHNThsRee8oRof/okF4pRN4c7I/P9l9GKGhOddsegSuQ6LBGw6o523V gtoY5e6iJpktzqZAM5BReGyBGlkxUChLAu0FwtE5QMRrYaRRqZz5El+SAJdsP3nMHib+ 92Fdk4DZw8JfSYpRRUDG/wav25olLCJEw8Jq4JsIb7TW40etbI2G0MNvVlwAXHiUxMS2 u06FKKVoTYqSX6WpzOY7k2lCZL9MmhxwIXzCNrIJXd9eDXyRekTK8/agon0BKcNBfVYu fw5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=Snq77pgWGuBdhSsfi8MS1XPk8bTI55UIIEAHYPZaB1Y=; b=crPY0ylVnXEweyPlutpS9o2offNbdx+KMrTDQPX9/b5tZRBs4dYvAvPZpKnUqLmHmi YQoRLJJtYPxu33uvcFCLiHZWkPe0JTrYHdMMN7A1dzfCNXvF94uVx9xX1outPKloUPZ7 dx9/bZpHcIWR0LIKtOPHAJT+I3y5PHv3EiMjMMEOw2nsFcr/KWFNEIEPE0YCJPDCJN8H NhBZ3gxl8un4Rpm3tvxpG/xfniWb0vFXqGRJ1Za7HO9yU46ab2L77LVu6e+ji8Ba5tgd PD3IVD1g5+r2CDGpl8BgUBOxakoLs+lUUYKlNXu4pp3ffRCP2b6eLI9K2NdFb+o5DExN E8JA== X-Gm-Message-State: ACgBeo1B7YS8TcHlF81QdYCUgnNu6Uz/+qS3HeypdYPzn//edITSc1lB Sc+p0lh+q1igk8ERFqLIfug= X-Google-Smtp-Source: AA6agR6wz/wRqsLGA1VDFCnrcJ6RF79Yt/qicnNT11CsJOqIpgO2RVF7xPfIkEvuXilrG2DkywD5VA== X-Received: by 2002:a17:902:9b98:b0:176:70e1:1f86 with SMTP id y24-20020a1709029b9800b0017670e11f86mr34884976plp.60.1663137237143; Tue, 13 Sep 2022 23:33:57 -0700 (PDT) Received: from hyeyoo ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id o9-20020a62cd09000000b0053e199aa99bsm9033475pfg.220.2022.09.13.23.33.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 23:33:56 -0700 (PDT) Date: Wed, 14 Sep 2022 15:33:50 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Vlastimil Babka Cc: kernel test robot , lkp@lists.01.org, lkp@intel.com, Joel Fernandes , linux-mm@kvack.org, rcu@vger.kernel.org, paulmck@kernel.org, Alexey Dobriyan , Matthew Wilcox Subject: Re: [mm/sl[au]b] 3c4cafa313: canonical_address#:#[##] Message-ID: References: <20220906074548.GA72649@inn2.lkp.intel.com> <208c1757-5edd-fd42-67d4-1940cc43b50f@intel.com> <416149c0-1e18-0e00-d116-dd3738957556@suse.cz> <3d178109-5981-f4ee-8fe5-4f1d0c557ed2@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663137238; a=rsa-sha256; cv=none; b=TnMqdspwnvrwZZCTM6LVKa2FazvmO3x44h/8++kNVGEC5MfiWCwR+yV3U/Wz0XJiTwxjv5 cFvOVLDYHhybuPkaABA/dw1oADFQcAkVIcci4BMoQ+G74g3U2N0GQVXR5z/LulV1ypQs6z ixq+UnIF5JmS83Lxw3EXCoazMsJteSo= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=aHOWylDR; spf=pass (imf02.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663137238; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Snq77pgWGuBdhSsfi8MS1XPk8bTI55UIIEAHYPZaB1Y=; b=UfUZCQ6tTkh5WxKM0fbrgf9OG9Is8pM9srGdaSvo8nNcBkk54pt/rxi7llsg2R3T+L8RH+ B6wynvugZgh0sVu7CY/8MEGTJ9iQDBLFTgMART4rOafeGaxJUG9RCJ45uZGXdZ68F9DUr7 iaQ48+tSYe1GDjDVD04f2ANvq+LnyD0= X-Rspam-User: Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=aHOWylDR; spf=pass (imf02.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam02 X-Stat-Signature: jsnxh5fqjusm3rkpnab5sfgyuq9hrgqn X-Rspamd-Queue-Id: 5653E800AD X-HE-Tag: 1663137238-507621 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 Fri, Sep 09, 2022 at 11:16:51PM +0200, Vlastimil Babka wrote: > On 9/9/22 16:32, Hyeonggon Yoo wrote: > > On Fri, Sep 09, 2022 at 03:44:19PM +0200, Vlastimil Babka wrote: > >> On 9/9/22 13:05, Hyeonggon Yoo wrote: > >> >> ----8<---- > >> >> From d6f9fbb33b908eb8162cc1f6ce7f7c970d0f285f Mon Sep 17 00:00:00 2001 > >> >> From: Vlastimil Babka > >> >> Date: Fri, 9 Sep 2022 12:03:10 +0200 > >> >> Subject: [PATCH 2/3] mm/migrate: make isolate_movable_page() skip slab pages > >> >> > >> >> In the next commit we want to rearrange struct slab fields to allow a > >> >> larger rcu_head. Afterwards, the page->mapping field will overlap > >> >> with SLUB's "struct list_head slab_list", where the value of prev > >> >> pointer can become LIST_POISON2, which is 0x122 + POISON_POINTER_DELTA. > >> >> Unfortunately the bit 1 being set can confuse PageMovable() to be a > >> >> false positive and cause a GPF as reported by lkp [1]. > >> >> > >> >> To fix this, make isolate_movable_page() skip pages with the PageSlab > >> >> flag set. This is a bit tricky as we need to add memory barriers to SLAB > >> >> and SLUB's page allocation and freeing, and their counterparts to > >> >> isolate_movable_page(). > >> > > >> > Hello, I just took a quick grasp, > >> > Is this approach okay with folio_test_anon()? > >> > >> Not if used on a completely random page as compaction scanners can, but > >> relies on those being first tested for PageLRU or coming from a page table > >> lookup etc. > >> Not ideal huh. Well I could improve also by switching 'next' and 'slabs' > >> field and relying on the fact that the value of LIST_POISON2 doesn't include > >> 0x1, just 0x2. > > > > What about swapping counters and freelist? > > freelist should be always aligned. > > Great suggestion, thanks! > > Had to deal with SLAB too as there was list_head.prev also aliasing > page->mapping. Wanted to use freelist as well, but turns out it's not > aligned, so had to use s_mem instead. > > The patch that isolate_movable_page() skip slab pages was thus dropped. The > result is in slab.git below and if nothing blows up, will restore it to -next > > https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git/log/?h=for-6.1/fit_rcu_head I realized that there is also relevant comment in include/linux/mm_types.h: > 62 * SLUB uses cmpxchg_double() to atomically update its freelist and counters. > 63 * That requires that freelist & counters in struct slab be adjacent and > 64 * double-word aligned. Because struct slab currently just reinterprets the > 65 * bits of struct page, we align all struct pages to double-word boundaries, > 66 * and ensure that 'freelist' is aligned within struct slab. > 67 */ Also we may add a comment, something like this? --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -79,6 +79,9 @@ struct page { * WARNING: bit 0 of the first word is used for PageTail(). That * means the other users of this union MUST NOT use the bit to * avoid collision and false-positive PageTail(). + * + * WARNING: lower two bits of third word is used for PAGE_MAPPING_FLAGS. + * using those bits can lead compaction code to general protection fault. */ union { struct { /* Page cache and anonymous pages */ -- Thanks, Hyeonggon