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 6FE73C43334 for ; Tue, 14 Jun 2022 11:30:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A04F28D0239; Tue, 14 Jun 2022 07:30:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98D068D0002; Tue, 14 Jun 2022 07:30:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 854C78D0239; Tue, 14 Jun 2022 07:30:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 71E6C8D0002 for ; Tue, 14 Jun 2022 07:30:11 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 314373494E for ; Tue, 14 Jun 2022 11:30:11 +0000 (UTC) X-FDA: 79576622622.14.CA9C04E Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) by imf04.hostedemail.com (Postfix) with ESMTP id CEB0B40093 for ; Tue, 14 Jun 2022 11:30:10 +0000 (UTC) Received: by mail-yb1-f176.google.com with SMTP id k2so14636783ybj.3 for ; Tue, 14 Jun 2022 04:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to:cc; bh=JAosT/mN4H1YOc1s3Ddsy3O1iZI8aroPGqskOSD9DU4=; b=R8XnWpvC7Mp/W1aLGWMGIq+kknUjZ8Qqg+uFUAmQkuWNVZ8rbqSwdfOPQFBLludIeO q7GptsYAwV9oqB+LqdUIAosP1gTivGU0OO3qeAdzsN/Ao0iqb9c8Gbyd+89e8/UYWnO2 YebqheSfsu6Lgklf7X7OWcNjwbpAVsSwjKON2TUcAwH9tRPDiF9XbKFSWdNTxhY4asm0 jLoUCZbsg+fAyK8xQl2N9dG5U02Q3TChTr7iTiXnyWfFgLUPVfayeykIF+99iCIQnLf6 iXzID9aSleZ8l/gJjgXVw55UgqLBsJAK79HlLshFdK9B9bKoP1NcZJ7i7XFfnjoomyV2 Z12g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=JAosT/mN4H1YOc1s3Ddsy3O1iZI8aroPGqskOSD9DU4=; b=EAtva8PAHxPD2jLscZ1uNH//BqI0GxT9Qq5msd7xvrnFUEeZUQFYKthNDWVbgFpDVC yAtPxIi+83dl3FXSWh/BwAQ9s23H2uLWB2FWYcovmp5IA8w4YUOgktsZll9EIh4xnpvw GcA0+wnFAk8C9Ub0hTrDiBtWTbSZQNSCmcQysIeKV9BOlWIHlnjzzAu6jllijlLrE0Ls R5LrHrNYMiwKhwfv4fFMiOhumLL19uju9qXwucfDAVmlyVpN0SWxwd5XPvytuqnipxCG hFOaAbPjh6KQwzui02VsZzygp6eGgTFrAhYfDNGm0QRG1Ja+UI8plYe7bAl+g1d5/Fvs 4Orw== X-Gm-Message-State: AJIora8HG3AUG8zlz1nEE6Qt3MRZSVRvRFky+/xjgK40j+TrJIx1czLH uJJrM3BozO5u1ATR3CK1W6jmRSwqz0WPAL7mNvU= X-Google-Smtp-Source: AGRyM1vFMZbf6PsD1FNQgLdFasC0oSx+6Z0l/vf29nj4Lzw79DkTBXNqnCgkEpBPxw9uyiSAh0di9Si0Lyu+LhDOsmE= X-Received: by 2002:a25:d50f:0:b0:64a:784b:960 with SMTP id r15-20020a25d50f000000b0064a784b0960mr4431684ybe.318.1655206209977; Tue, 14 Jun 2022 04:30:09 -0700 (PDT) MIME-Version: 1.0 From: Lukas Bulwahn Date: Tue, 14 Jun 2022 13:29:59 +0200 Message-ID: Subject: Issue in count_mm_mlocked_page_nr() with commit afcf76df48f9 ("mm/mlock: use vma iterator and maple state instead of vma linked list") To: "Matthew Wilcox (Oracle)" , "Liam R. Howlett" , "maple-tree@lists.infradead.org" Cc: Linux-MM , Linux Kernel Mailing List , Andrew Morton , kernel-janitors Content-Type: multipart/alternative; boundary="0000000000002d02c605e166bae5" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655206210; 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: references:dkim-signature; bh=JAosT/mN4H1YOc1s3Ddsy3O1iZI8aroPGqskOSD9DU4=; b=QmcUWWmMUp9LhJUc0VEoMNwRdmdqDbvuj3S9fBNqdTjCwxXeQxIL1KL7hqQaHVUqnRa1m7 AilBJSXJTPgVfqp65XQbg5uQufo336fAedeDcBrdyiqgYEnacntoWfjsfqbcNUEuJFLPF7 xF0mSzokb6CVc1PhiEvF7PElPHwfGlY= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=R8XnWpvC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of lukas.bulwahn@gmail.com designates 209.85.219.176 as permitted sender) smtp.mailfrom=lukas.bulwahn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655206210; a=rsa-sha256; cv=none; b=Z78u2CppHXswUFGQH9lv3gS6aFGwuFbulDx7ImK09B7DX3dZWVYCS3lvyrhhh0uq4NcZO4 mQu9lZ1Qdx0KSCWM+StA2PudFb8XEVm5AaMPho5jeugtgCJfQcdkplGwq7UV5bm1jcQIpg Nv9YT3IupYqpMcqQOol+sA8ml9M/6tM= X-Stat-Signature: ppqxc7afuuxxjcmwd3ypqm3npq8hx5ia X-Rspamd-Queue-Id: CEB0B40093 X-Rspam-User: X-Rspamd-Server: rspam05 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=R8XnWpvC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of lukas.bulwahn@gmail.com designates 209.85.219.176 as permitted sender) smtp.mailfrom=lukas.bulwahn@gmail.com X-HE-Tag: 1655206210-264415 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: --0000000000002d02c605e166bae5 Content-Type: text/plain; charset="UTF-8" Dear Matthew, dear Liam, The commit afcf76df48f9 ("mm/mlock: use vma iterator and maple state instead of vma linked list") refactors the function count_mm_mlocked_page_nr() in mm/mlock.c, such that the special case: if (mm == NULL) mm = current->mm; is now dead code. Before the refactoring, after this if statement, the variable mm was used further in vma = find_vma(mm, start) in the following line, but now, with the introduction of VMA_ITERATOR(vmi, mm, start) before the if statement, the assignment within the if statement is simply ignored. I assume that: - If the semantics of this function shall be preserved, the VMA_ITERATOR macro needs to move after the if statement. - or, if the consideration of the special case on mm == NULL is actually obsolete with this refactoring, it could be simply deleted. I will keep it up to you how this issue is correctly resolved. This was discovered due to tracking all dead stores that clang-analyzer reports on an x86 defconfig. The underlying issue here is more severe than "just a dead store in the kernel code base", but it is probably easy for you to resolve. Best regards, Lukas --0000000000002d02c605e166bae5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Dear Matthew, dear Liam,

The commit afcf76df48= f9 ("mm/mlock: use vma iterator and maple state instead
of vma link= ed list") refactors the function count_mm_mlocked_page_nr() in
mm/m= lock.c, such that the special case:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (= mm =3D=3D NULL)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = mm =3D current->mm;

is now dead code. Before the refactoring, aft= er this if statement, the variable
mm was used further in vma =3D= find_vma(mm, start) in the following line, but now,
with the introducti= on of VMA_ITERATOR(vmi, mm, start) before the if statement,
the assignme= nt within the if statement is simply ignored.

I assume that:
- If= the semantics of this function shall be preserved, the VMA_ITERATOR macro<= br>needs to move after the if statement.

- or, if the consideration = of the special case on mm =3D=3D NULL is actually
obsolete with this ref= actoring, it could be simply deleted.

I will keep it up to you how t= his issue is correctly resolved.

This was discovered due to tracking= all dead stores that clang-analyzer reports
on an x86 defconfig. The un= derlying issue here is more severe than "just a dead
store in the k= ernel code base", but it is probably easy for you to resolve.

B= est regards,

Lukas
--0000000000002d02c605e166bae5--