Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2714575rwb; Fri, 20 Jan 2023 06:34:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXtp/eZgYgftwBMrKYZtijgNclZPHoqfcAAmhlvNrQ/31Bb9xKa9m9qxkhEBBPnC/Y5LUqkS X-Received: by 2002:a05:6402:28ca:b0:49c:96f9:417e with SMTP id ef10-20020a05640228ca00b0049c96f9417emr15141970edb.2.1674225262664; Fri, 20 Jan 2023 06:34:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674225262; cv=none; d=google.com; s=arc-20160816; b=rMRTl01bVeUrv8uv8ffyyWYevCRBZjZ6ZbQhFaX5U2v57Vkb4drrPNGk4/uiHvm+y/ w8g3PNm698ym9bEVzdOxIhfuqW/AAdLy6SONHBptPEiDbAjEJDDwVpn+qEH24gjy/twO H78oqs5iEoNJ8iJeyKF4ziMlFNZm6NFgyajt748xg/qRHrR5xVXdqlDmdvfRhUX/aaQK 2VCZz0HfLNPbEiS/4nEWqVBG0mf1W8eUZ7dOAj25fmCB0fW2DyO/pWRMROVoqAcFuHXa Cnj2cdIHAPJirEdlWEg66/jKkizaKk7y44cKuUFlt+rdwwCc+O/oddbe8ZM3KQg22S36 YORA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature :dkim-signature:date; bh=NsKNz+h7l7zK73sE5jHBFOsX4kUSjPMG5HGuXT67KNU=; b=AKFwaTpLB03fEYtQ2V5wBWp642SWC8BALOdZkEDa9TZXyEbh+UlmFI/9j6p2ng456U Le9g9QnZiRgPZABG9raVPK5FW4DwozZpVBuPGz6+YBhBQ51sKJ1YkCno48ulsiHtrNFz IU0hjyOBxZbvjqOsqOV7HkTaIbQ4NwmBd8GFBKlkBY95JpKmpUjfOTgEqpg1RVteUDGC EK48QCExi+IE8qC+TZLT1y9ShbPVFHRK3zcvCrfYQCdsCs/B74ZTZh3+RlKXYPEmL08a 1XsEVRi0vJ6FIeKjHWyybXy0ccT+OjlrK6musXMFJZK4ANjnqCMkfAVsS3AfAo2TRCv5 EWag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="hMVb0C/q"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm2-20020a0564020b0200b0049bac85dfb6si22158674edb.19.2023.01.20.06.34.09; Fri, 20 Jan 2023 06:34:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="hMVb0C/q"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbjATNij (ORCPT + 49 others); Fri, 20 Jan 2023 08:38:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjATNii (ORCPT ); Fri, 20 Jan 2023 08:38:38 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 372035421A; Fri, 20 Jan 2023 05:38:30 -0800 (PST) Date: Fri, 20 Jan 2023 14:38:27 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1674221908; 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: in-reply-to:in-reply-to:references:references; bh=NsKNz+h7l7zK73sE5jHBFOsX4kUSjPMG5HGuXT67KNU=; b=hMVb0C/qwtLknqlm9ZTWsZp8gViVTHq3936ul8+F/rjZ2C/sgt5+DFrbylMt7YcpAHU3oH s5YRhw0mbmU5xAOUw11TSsuYNR6BabwKiK0BUZH6EnHXFtJrzjrfU7+jk9sLeRQFhl52bM noYQvDhJmie3ohgf6vlqG25yiFWOsAwo294gs5CU+91q19gh2Ous1s4W2gLWSXf4hfFq5g N/SSCNdKYGIkOYGevx1ji2XNC15o/itV2b+YKslr31hccta4mAL/107ExcW87kQo7dXxix HZ6fc5RqejZNFrSOnc60iWEfw7mR8Tr5XafJoL8j51qB5CsHiSldM4D/A+x0Yw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1674221908; 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: in-reply-to:in-reply-to:references:references; bh=NsKNz+h7l7zK73sE5jHBFOsX4kUSjPMG5HGuXT67KNU=; b=1/EOPOv6QyXT4fegGzYXsWuax92mLA9Ez2GeK/k4fouB6Yl9u7shmtVu/E/cx6Mcn5/W6Z NQC1tgrEqUl2cjDA== From: Sebastian Andrzej Siewior To: Mel Gorman Cc: Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Davidlohr Bueso , Linux-RT , LKML Subject: Re: [PATCH v2] locking/rwbase: Prevent indefinite writer starvation Message-ID: References: <20230117165021.t5m7c2d6frbbfzig@techsingularity.net> <20230118173130.4n2b3cs4pxiqnqd3@techsingularity.net> <20230119110220.kphftcehehhi5l5u@techsingularity.net> <20230119174101.rddtxk5xlamlnquh@techsingularity.net> <20230120132441.4jjke47rnpikiuf5@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230120132441.4jjke47rnpikiuf5@techsingularity.net> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-01-20 13:24:41 [+0000], Mel Gorman wrote: > --- a/kernel/locking/rwbase_rt.c > +++ b/kernel/locking/rwbase_rt.c > @@ -264,12 +291,17 @@ static int __sched rwbase_write_lock(struct rwbase_rt *rwb, > if (__rwbase_write_trylock(rwb)) > break; > > + /* Record timeout when reader bias is ignored. */ > + rwb->waiter_timeout = jiffies + RWBASE_RT_WAIT_TIMEOUT; rwb->waiter_timeout = (jiffies + RWBASE_RT_WAIT_TIMEOUT) | 1; There is the unlikely case that (jiffies + RWBASE_RT_WAIT_TIMEOUT) = 0 on 32bit where it is not jiffies64. Reviewed-by: Sebastian Andrzej Siewior > + > raw_spin_unlock_irqrestore(&rtm->wait_lock, flags); > rwbase_schedule(); > raw_spin_lock_irqsave(&rtm->wait_lock, flags); > > set_current_state(state); > } > + > + rwb->waiter_timeout = 0; > rwbase_restore_current_state(); > trace_contention_end(rwb, 0); Sebastian