Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp891940pxb; Wed, 27 Oct 2021 14:35:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzUXC4BEUVnt3JoGN96aP2M2X1/vl2RoTbi7/4UFjxKihk/PT+JOvs1BK1kT/7dRqBGK0F X-Received: by 2002:a17:907:2daa:: with SMTP id gt42mr171733ejc.4.1635370507303; Wed, 27 Oct 2021 14:35:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635370507; cv=none; d=google.com; s=arc-20160816; b=H8FdZ1PjtdfiufKjLngpBecZnb8YZh6si4prKtw0wmyCz16EMTdp7PyB/MAfGztxl6 kzqhsUHhv9AcKBVv8bin19cfQ4VnDw/AcFLULPooeHvaVLk/lZJkBwVTJgGz6yDI8WkY /rS+39lWLeNNY9knD34dZ7DII/YD/ZXyKTsBR/VEvXPvLVYKyQbzmJGDyaX15C8PEhfA YVeuf197phVynLX0gDE9T8UxezCzyC9q8C6Ro/sWW4fkcZT95jTxG5Yn58RxeNVAwsfA MUgbBo1KAX9lEDy5UdvxuOYw6UxXZ8M6yiCFQ9O6D4eMyD1c8rEsQmzKlgVO+lHcnswk GyCQ== 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=2PjuNeHqkEC+TnHGw+HkK8UIEzWJEETPPBQlrocuPTU=; b=Wj4n2o5AqYL0rIOF526daJfyBFIHTMSNhbrlh02nvTKEjbPtShnhYs5uia37YRbfsl 0b4wIQLCUSOLrvd6zTdedg2NOWovhSNEHL215NGW5jokuV4m4aNXWOoAAc65FPV+Ko4b SbdP1sjVAsALnEBWZdvUTadkd++Tz+y1fDFtvQonKePCB4JClzctKAlGJS3P9GfbSkK3 wMf5bgwC8CVRV9WivOsp/bLOkR3jIwWlxmtadfRVbwmt0oQvJmRjJ0p68aOsOrscbO5Z l7DIyFieFaxCBgxZ3riGsiqOyEiHwr80cpdVL5Akww+jvBq23IfwdRizM8iLomhCnAdy /pTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=lLMbuFSO; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z10si1170783ejg.497.2021.10.27.14.34.44; Wed, 27 Oct 2021 14:35:07 -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=@soleen.com header.s=google header.b=lLMbuFSO; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243515AbhJ0SZO (ORCPT + 97 others); Wed, 27 Oct 2021 14:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236888AbhJ0SZO (ORCPT ); Wed, 27 Oct 2021 14:25:14 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3515C061570 for ; Wed, 27 Oct 2021 11:22:47 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id 205so6156431ljf.9 for ; Wed, 27 Oct 2021 11:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2PjuNeHqkEC+TnHGw+HkK8UIEzWJEETPPBQlrocuPTU=; b=lLMbuFSOE+jF05Bi6R4jcYzGGMqVatV0odlAiYllsUoS+qAXv+ZpDMJuO5RzvOZQdR D5tjHrdYUtdnoQJ2rdnv/Enk+JCyKcnZYsLwSvVUd2I146BN/2hQLFX930ofc0g8kChC LJLBtzwRRmFlnqrm6RLIGt7FmuYCoS3sn+evJa3IP7AyvkYRDCV58BO4FURlVuUuyFZD 3WHotNhKoHU90flIseiCDMZliZTbAy9pi6BHt0mF+npdL26WjVvhqge51TReCgfRK65U YtNs40Mn+uDoVgm3W0QrcKs/y6Ne4Cg7ShmPQayK69U5W0XAoyiwEvLGrevriNMj3FH1 pOeQ== 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=2PjuNeHqkEC+TnHGw+HkK8UIEzWJEETPPBQlrocuPTU=; b=zByH6+jdiQwQmTvowmAL/fyNiY+C9358r0/mjjW2XK15924E+7UcV8wLCAqK7j7D8V tK4JwEU58WdmhrcQstfjAJSzxri+CM+9KqXlEpCLD1J2X3ktZf3I6E4xI/s/zbPh1KqL 0tsPDd08I7gWhnTZizYaecFSoua4cMkRMbzv3RP/0UdB65Zhf4sqF38+utN0tm2YbiDF 4ExoX0Jvlla8eywdrPJZLpVnvMbJ41UDSNuT1A+ifH9hB4KDzYPz9efPckPLph34YUWg 2z6Pn+bY9+/eDtb+calYkd4nSxSUbNl9ZFI/Hix/39iAHs746zUuE4hvht5UYwKwgIr+ 0xPw== X-Gm-Message-State: AOAM532Od+1cn95xBS/HaDo63cw9q4tKJP9nzu0wWXbjceEP89tlv8RZ UZTXtITRkj2sBg/bxgVw2PclsjdeoQhhmpuvcNbqBw== X-Received: by 2002:a05:651c:c3:: with SMTP id 3mr4927747ljr.355.1635358966211; Wed, 27 Oct 2021 11:22:46 -0700 (PDT) MIME-Version: 1.0 References: <20211026173822.502506-1-pasha.tatashin@soleen.com> <20211026173822.502506-2-pasha.tatashin@soleen.com> In-Reply-To: From: Pasha Tatashin Date: Wed, 27 Oct 2021 14:22:08 -0400 Message-ID: Subject: Re: [RFC 1/8] mm: add overflow and underflow checks for page->_refcount To: Muchun Song 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 Uytterhoeven , 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 > I found some atomic_add/dec are replaced with atomic_add/dec_return, I am going to replace -return variants with -fetch variants, potentially -fetch > 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. The generic variant uses arch_cmpxchg() for all atomic variants without any extra barriers. Therefore, on platforms that use generic implementations there won't be performance differences except for an extra branch that checks results when VM_BUG_ON is enabled. On x86 the difference between the two is the following atomic_add: lock add %eax,(%rsi) atomic_fetch_add: lock xadd %eax,(%rsi) atomic_fetch_add_relaxed: lock xadd %eax,(%rsi) No differences between relaxed and non relaxed variants. However, we used lock xadd instead of lock add. I am not sure if the performance difference is going to be different. Pasha