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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBA0DC433DF for ; Sat, 20 Jun 2020 20:48:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 870C62469C for ; Sat, 20 Jun 2020 20:48:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="grY8u+R5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 870C62469C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D76C88D0011; Sat, 20 Jun 2020 16:48:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D01828D0008; Sat, 20 Jun 2020 16:48:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC73E8D0011; Sat, 20 Jun 2020 16:48:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id A1E338D0008 for ; Sat, 20 Jun 2020 16:48:13 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2F4BA181AC9CC for ; Sat, 20 Jun 2020 20:48:13 +0000 (UTC) X-FDA: 76950777666.24.cloud92_0c0da0026e24 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 0D2BE1A4A0 for ; Sat, 20 Jun 2020 20:48:13 +0000 (UTC) X-HE-Tag: cloud92_0c0da0026e24 X-Filterd-Recvd-Size: 4460 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Sat, 20 Jun 2020 20:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592686092; h=from:from: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; bh=kcnVcw2BsdiV3cf0d7OYXHmXnlCa3e+D0j3FNWSgmpE=; b=grY8u+R5hzoNbWdljwQJpJPvjoU8Tn99MlzGxwhspl5K3lhW0H05mSyKNOVyTmAvli4RxV 3LI09ADxiJO4Lt7Dywn/YNQbo64D2Hg390Nq88CULxqxq8CO9gJcyi9tTag8lwg+uzoxeP tLYdmCn9JVLGq8je3WfRD55vKPvGuIo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-415-AaOvkQczOQy-BgVUM84z4Q-1; Sat, 20 Jun 2020 16:48:07 -0400 X-MC-Unique: AaOvkQczOQy-BgVUM84z4Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1BDA107ACCA; Sat, 20 Jun 2020 20:48:04 +0000 (UTC) Received: from llong.remote.csb (ovpn-112-81.rdu2.redhat.com [10.10.112.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D2455BAE0; Sat, 20 Jun 2020 20:48:02 +0000 (UTC) Subject: Re: [PATCH] mm, slab: Fix sign conversion problem in memcg_uncharge_slab() To: Roman Gushchin Cc: Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Johannes Weiner , Shakeel Butt , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20200620184719.10994-1-longman@redhat.com> <20200620195905.GA286724@carbon.DHCP.thefacebook.com> From: Waiman Long Organization: Red Hat Message-ID: <7711a89c-340c-c95b-5857-83baa502322d@redhat.com> Date: Sat, 20 Jun 2020 16:48:01 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200620195905.GA286724@carbon.DHCP.thefacebook.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Rspamd-Queue-Id: 0D2BE1A4A0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 6/20/20 3:59 PM, Roman Gushchin wrote: > On Sat, Jun 20, 2020 at 02:47:19PM -0400, Waiman Long wrote: >> It was found that running the LTP test on a PowerPC system could produce >> erroneous values in /proc/meminfo, like: >> >> MemTotal: 531915072 kB >> MemFree: 507962176 kB >> MemAvailable: 1100020596352 kB >> >> Using bisection, the problem is tracked down to commit 9c315e4d7d8c >> ("mm: memcg/slab: cache page number in memcg_(un)charge_slab()"). >> >> In memcg_uncharge_slab() with a "int order" argument: >> >> unsigned int nr_pages = 1 << order; >> : >> mod_lruvec_state(lruvec, cache_vmstat_idx(s), -nr_pages); >> >> The mod_lruvec_state() function will eventually call the >> __mod_zone_page_state() which accepts a long argument. Depending on >> the compiler and how inlining is done, "-nr_pages" may be treated as >> a negative number or a very large positive number. Apparently, it was >> treated as a large positive number in that PowerPC system leading to >> incorrect stat counts. This problem hasn't been seen in x86-64 yet, >> perhaps the gcc compiler there has some slight difference in behavior. >> >> It is fixed by making nr_pages a signed value. For consistency, a >> similar change is applied to memcg_charge_slab() as well. >> >> Fixes: 9c315e4d7d8c ("mm: memcg/slab: cache page number in memcg_(un)charge_slab()"). >> Signed-off-by: Waiman Long > Good catch! > > Interesting that I haven't seen it on x86-64, but it's reproducible on Power. > > Acked-by: Roman Gushchin > I think it is probably related to the level of inlining that are being done. Besides, the interpretation of -nr_pages is ambiguous if nr_pages is an unsigned value and different compilers may handle it differently when sign extension is needed. Cheers, Longman