Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp852240pxb; Wed, 27 Oct 2021 13:45:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkGouocASkF/PIILBVgsNBQQ6W/Ix8ChWfEqHQD6JE4lEFnlN8jvvU70PGRx+2n5uQwDzu X-Received: by 2002:a17:906:af72:: with SMTP id os18mr42411813ejb.331.1635367516276; Wed, 27 Oct 2021 13:45:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635367516; cv=none; d=google.com; s=arc-20160816; b=04uTOJkEqnLTs7aQs9N8LjLG4wpJs4y3nLpfbGDrWQ+s6IiTJQ62g+6VOzaBnF/ujH 06wicHso+w2H6E9TXaSiBqIlvs5sZTouwo46/58oh71PK8wUUfjEG+6cNauBWbGsYs/f Wnbel/QhnLmYecoj7XWCvPwb1aDPHr+dr7u3YC2DAlG+BHGV9kiqW20mR6Xyizy94qu3 w+VCIcQ/lLkUDI7bzMwuFfru9/aGuiaoh+CK7Xy/ZTthzlzwqT0XiGS4h9h7lSDFe0F7 YyDUuKA5dXbJE2KT4AI5sJHNk9m/UZTdK1z9v1n4j+P1GfjcTQ1Vc/HivGxeC/YC7QdT m0Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=loo6J+IxIj4clOI8hbAYwr44QCVgT2WqP23IkmlyE90=; b=FSDNdOgDDMnN/cuh//Ios7N5XNOYgvdRirdx7Qq8iwdhZFMLVaIchfnrPKJgLN/gO6 xxYL8LT8BSNvGZrWmelzwWw0xAyppfIReM9gjSWtXJBbvjxU8uYi7GcuLjEID0Huh3Fk P3pUbNq31aTjsA4BkB8I7FoMgSf0D6EvDlKsAwCle2KsVEpCQfSsyVTq83nue/uy4/By wF2HEGB843saK7dR/xYEOe10RMkWtvmVwkEkDiqYMQ1lK9KLEUueEsgKW3NMvI6u/ime V2ibwP9EE2TxBcXisiNcQ46Inc8tFbka5Xd1NPmgqGbAytJ3fO+s9EsluaeMbFw97Had tyWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=ejNHgkTE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h13si1211951ejs.401.2021.10.27.13.44.52; Wed, 27 Oct 2021 13:45:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=ejNHgkTE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231709AbhJ0Htr (ORCPT + 99 others); Wed, 27 Oct 2021 03:49:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231620AbhJ0Htq (ORCPT ); Wed, 27 Oct 2021 03:49:46 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66EFEC061570 for ; Wed, 27 Oct 2021 00:47:21 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id i65so4161261ybb.2 for ; Wed, 27 Oct 2021 00:47:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=loo6J+IxIj4clOI8hbAYwr44QCVgT2WqP23IkmlyE90=; b=ejNHgkTEI3rvzEqVdyGTwC4ZsTd3PDCtXvqQq6h7xYm339qXrcU/LTl4td5IJ9K80l PDNmBPPXvQvVaBiiZy7PN77C7Czz+NStfGWc39W0PiK9prM9AT9f9ivIUH3nZFIriI5F DqBL6YR/3Pd9WTECoGr0FNUp0mAdSqAJ7x9IvKOjAF4Eei+IrsiX3gCMIpSS8lnvQcfO tPV9rmIQvzqweHp9j7FRlN2Aj2U94P3ECNMGnwpExpWsaG1pcGzR7r6cwjmGGRlxZ+mv ldbrKEaIAHjOHVr8Oia34oebIlHlXXUlIpNgUsWRdXVA3jtrqvR+tD1bkjSJLRjLJwUp 2Ykw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=loo6J+IxIj4clOI8hbAYwr44QCVgT2WqP23IkmlyE90=; b=sAYfNwmOyurNXPl+mwJf2m3X2d9bDr2TaQaYx0qTLwzLiEitoYQ+4da5Vi+TAqOqb4 cK48f44wnRIrG33kNO5P13FQX4ETdz2TDmz7h7DnVetocEK45guGJeKhituTWIrZCLp7 RWq1gtczsZQaFXRUfO2mwe0GEo4oFY59hNChn19AUAyu0ja4Q3NsBz/3OqDnIMickl6v xhzexaZit1KEAO2zT8hBy/UJQAfTq7x8rZydkE9X+MmZFPRvjHlu7xh0t/eCDULlUUKb esBiFRBiTqio60qeS4WORHQGwJUYrpxWV9ZZ4OXqJbuhbOEKgXjY+HPkhhzFOGqT3PJb WXIA== X-Gm-Message-State: AOAM531iesJYA1GYhXKkZDSr20stAZw6Hi0kaRIJMfeMsSEYwyJWoihB okOJpcBgixXQOD+RuJsAr4tuMdyWWVMYlgP/9qhR2PaDxX0/mg== X-Received: by 2002:a25:3b50:: with SMTP id i77mr1035222yba.404.1635320840664; Wed, 27 Oct 2021 00:47:20 -0700 (PDT) MIME-Version: 1.0 References: <20211026173822.502506-1-pasha.tatashin@soleen.com> <20211026173822.502506-2-pasha.tatashin@soleen.com> In-Reply-To: <20211026173822.502506-2-pasha.tatashin@soleen.com> From: Muchun Song Date: Wed, 27 Oct 2021 15:46:42 +0800 Message-ID: Subject: Re: [RFC 1/8] mm: add overflow and underflow checks for page->_refcount To: Pasha Tatashin Cc: LKML , Linux Memory Management List , linux-m68k@lists.linux-m68k.org, Anshuman Khandual , Matthew Wilcox , Andrew Morton , william.kucharski@oracle.com, Mike Kravetz , Vlastimil Babka , geert@linux-m68k.org, schmitzmic@gmail.com, Steven Rostedt , Ingo Molnar , Johannes Weiner , Roman Gushchin , weixugc@google.com, Greg Thelen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 27, 2021 at 1:38 AM Pasha Tatashin wrote: > > The problems with page->_refcount are hard to debug, because usually > when they are detected, the damage has occurred a long time ago. Yet, > the problems with invalid page refcount may be catastrophic and lead to > memory corruptions. > > Reduce the scope of when the _refcount problems manifest themselves by > adding checks for underflows and overflows into functions that modify > _refcount. > > Signed-off-by: Pasha Tatashin I found some atomic_add/dec are replaced with atomic_add/dec_return, those helpers with return value imply a full memory barrier around it, but others without return value do not. Do you have any numbers to show the impact? Maybe atomic_add/dec_return_relaxed can help this. Thanks.